Currently, we have a file called operations.js
which contains functions that interact with the database. The db interaction methods themselves come from the Mongoose
ORM.
operations.js
const mongoose = require('mongoose')
const Chair = require('./chairModel')
export const getChairFromDb = chairId => Chair.findOne({ _id: chairId }).exec()
export const createChairInDb = args => {
const newChair = new Chair(args)
return newChair.save()
}
I just wanted to check if operations.js would be the best name for this file, and if the functions getChairFromDb
and createChairInDb
would best be referred to as operations.
Aucun commentaire:
Enregistrer un commentaire