import { Document } from 'mongoose' ; import Review , { IReviewSchema } from '../models/Review' ; import { IGetReviewsQuery , IReviewQuery } from '../types' ; import { getReviewUpdate } from '../utils' ; export const get = ( query ) => Review . getReviews ( query ) ; export const find = ( body ) => Review . find ( body ) ; export const findById = ( id ) => Review . findById ( id ) ; export const findOne = ( body ) => Review . getSingle ( body ) ; export const create = async ( body ) => { const { entry , user } = body ; const updates = getReviewUpdate ( body ) ; await Review . updateOne ( { entry , user } , updates , { runValidators : true , setDefaultsOnInsert : true , upsert : true , } ) ; } ; export const remove = ( id ) => Review . findByIdAndRemove ( id ) ;