Instantly share code, notes, and snippets.

View $group
db.tvshow.aggregate([
{
$group: {
_id: {
rating: "$rating.average",
network: "$network.name",
},
total: {
$sum: 1
}
View $group
db.tvshow.aggregate([
{
$group: {
_id: {
rating: "$rating.average",
},
total: {
$sum: 1
}
}
View database-tv.json
[{"id":1,"url":"http://www.tvmaze.com/shows/1/under-the-dome","name":"Under the Dome","type":"Scripted","language":"English","genres":["Drama","Science-Fiction","Thriller"],"status":"Ended","runtime":60,"premiered":"2013-06-24","officialSite":"http://www.cbs.com/shows/under-the-dome/","schedule":{"time":"22:00","days":["Thursday"]},"rating":{"average":6.5},"weight":91,"network":{"id":2,"name":"CBS","country":{"name":"United States","code":"US","timezone":"America/New_York"}},"webChannel":null,"externals":{"tvrage":25988,"thetvdb":264492,"imdb":"tt1553656"},"image":{"medium":"http://static.tvmaze.com/uploads/images/medium_portrait/0/1.jpg","original":"http://static.tvmaze.com/uploads/images/original_untouched/0/1.jpg"},"summary":"<p><b>Under the Dome</b> is the story of a small town that is suddenly and inexplicably sealed off from the rest of the world by an enormous transparent dome. The town's inhabitants must deal with surviving the post-apocalyptic conditions while searching for answers about the dome, wh
View Draft.js
...
import { stateToHTML } from "draft-js-export-html";
import Parser from "html-react-parser";
...
render() {
var { editorState } = this.state;
return (
<div>
<Formik
View Terminal
yarn add draft-js-export-html html-react-parser
View CustomDraft.js
import React from "react";
import { Editor } from "react-draft-wysiwyg";
import "react-draft-wysiwyg/dist/react-draft-wysiwyg.css";
class CustomDraft extends React.Component {
render() {
console.log(this.props);
return (
<div className="form-group" style={{ width: "80%" }}>
<Editor
View FormField.js
import React from "react";
import { Form } from "formik";
import CustomDraft from "./CustomDraft";
export default props => (
<Form>
<CustomDraft {...props} />
<button type="submit">Submit</button>
</Form>
);
View Draft.js
import React, { Component } from "react";
import { Formik } from "formik";
import FormField from "./FormField";
import {
EditorState,
convertToRaw,
convertFromRaw
} from "draft-js";
export default class Draft extends Component {
View DraftContainer.js
import React, { Component } from "react";
import Draft from "../components/Draft";
import Context from "../contexts";
export default class DraftContainer extends Component {
static contextType = Context;
render() {
return (
<div>
<Draft />
View App.js
import React, { Component } from "react";
import Context from "./contexts";
import DraftContainer from "./containers/DraftContainer";
class App extends Component {
constructor(props) {
super(props);
this.state = {};
}
render() {