This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| age | gender | fruit | |
|---|---|---|---|
| 20 | 1 | apple | |
| 23 | 1 | apple | |
| 25 | 1 | apple | |
| 26 | 1 | orange | |
| 29 | 1 | orange | |
| 30 | 1 | orange | |
| 31 | 1 | Watermelon | |
| 33 | 1 | Watermelon | |
| 37 | 1 | Watermelon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { commitMutation, graphql } from 'react-relay'; | |
| import environment from '../../../../environment'; | |
| const mutation = graphql` | |
| mutation deleteNoteMutation($_id: ID) { | |
| deleteNote(_id: $_id) | |
| } | |
| `; | |
| function deleteNoteMutation(_id) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { commitMutation, graphql } from 'react-relay'; | |
| import environment from '../../../../environment'; | |
| const mutation = graphql` | |
| mutation updateNoteMutation($content: String, $_id: ID) { | |
| updateNote(_id: $_id, content: $content) { | |
| _id | |
| content | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { commitMutation, graphql } from 'react-relay'; | |
| import environment from '../../../../environment'; | |
| const mutation = graphql` | |
| mutation createNoteMutation($content: String) { | |
| createNote(content: $content) { | |
| _id | |
| content | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import React, { useState } from 'react'; | |
| import createNoteMutation from './mutations/createNote'; | |
| import deleteNoteMutation from './mutations/deleteNote'; | |
| import updateNoteMutation from './mutations/updateNote'; | |
| const MainPage = ({ notes }) => { | |
| const [newNote, setNewNote] = useState(''); | |
| const [noteContentBeingUpdated, setNoteContentBeingUpdated] = useState(''); | |
| const [noteIdBeingUpdated, setNoteIdBeingUpdated] = useState(''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // App.js | |
| import React from 'react'; | |
| import { graphql, QueryRenderer } from 'react-relay'; | |
| import MainPage from './containers/MainPage'; | |
| import environment from '../environment'; | |
| export default class App extends React.Component { | |
| render() { | |
| return ( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Environment, Network, RecordSource, Store } from 'relay-runtime'; | |
| function fetchQuery(operation, variables) { | |
| return fetch('http://localhost:4000', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json' | |
| }, | |
| body: JSON.stringify({ | |
| query: operation.text, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Mutation { | |
| createNote(content: String): Note | |
| deleteNote(_id: ID): ID | |
| updateNote(_id: ID, content: String): Note | |
| } | |
| type Note { | |
| _id: ID | |
| content: String | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const MongoDbRepo = require('../repository/mongoDbRepository'); | |
| class NoteService { | |
| constructor() { | |
| this.NoteRepository = new MongoDbRepo('Notes'); | |
| } | |
| getAllNotes() { | |
| return this.NoteRepository.getAll(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { getDB } = require('../config/databaseConnection'); | |
| const ObjectId = require('mongodb').ObjectId; | |
| class MongoDbRepo { | |
| constructor(collectionName) { | |
| this.collection = getDB().collection(collectionName); | |
| } | |
| getAll() { | |
| return new Promise((resolve, reject) => { |
NewerOlder