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 createCoin = require('./createCoin'); | |
| const updateCoin = require('./updateCoin'); | |
| const deleteCoin = require('./deleteCoin'); | |
| module.exports = { createCoin, updateCoin, deleteCoin } |
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 coins = require('./coins.js'); | |
| module.exports = { coins } |
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 Query{ | |
| coins: [ERC20Coin] | |
| } | |
| ... | |
| type Mutation{ | |
| createCoin(input: CreateERC20CoinInput!): ERC20Coin! | |
| updateCoin(id: ID, input: UpdateERC20CoinInput!): ERC20Coin! | |
| deleteCoin(id: ID): DeletePayload! |
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
| module.exports = async (_, {id}, {models}) => { | |
| const deleteCoin = await models.ERC20Coin.deleteOne({_id: id}); | |
| if(deleteCoin.deletedCount) return{id: 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
| const { models } = require("mongoose") | |
| module.exports = async (_, {id, input}, {models}) => { | |
| const ERC20CoinToUpdate = await models.ERC20Coin.findOne({_id: id}); | |
| Object.keys(input).forEach(value => { | |
| ERC20CoinToUpdate[value] = input[value]; | |
| }); | |
| const updatedERC20Coin = await ERC20CoinToUpdate.save(); |
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
| module.exports = async (_, {input}, {models}) => { | |
| newERC20Coin = await models.ERC20Coin.create(input); | |
| return newERC20Coin; | |
| } |
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
| module.exports = async (_, {}, {models}) => { | |
| return await models.ERC20Coin.find(); | |
| } |
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 {ERC20Coin} = require('./coin'); | |
| module.exports = [ | |
| ERC20Coin | |
| ] |
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 mongoose = require("mongoose"); | |
| const { Schema } = mongoose; | |
| const erc20CoinSchema = new Schema({ | |
| name: { | |
| type: String, | |
| trim: true | |
| } | |
| }); |
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 ERC20Coin = require('./coin'); | |
| module.exports = [ | |
| ERC20Coin | |
| ] |