import User , { IUserModel } from '../models/User' ; import { getFeedbackUpdates } from '../utils' ; export const find = ( telegram_id ) => User . findOne ( { telegram_id } ) ; export const create = ( telegram_id , userData ) => User . findOneAndUpdate ( { telegram_id } , userData , { new : true , setDefaultsOnInsert : true , upsert : true , } ) ; export const setReviewingFlag = async ( telegram_id , flag = true ) => { return User . findOneAndUpdate ( { telegram_id , reviewing : { $ne : flag } } , { reviewing : flag } , { new : true , } ) . lean ( ) ; } ; export const updateLikes = async ( telegram_id , userData ) => { const updates = getFeedbackUpdates ( userData ) ; return User . findOneAndUpdate ( { telegram_id } , { ... updates , reviewing : false } , { new : true , } ) . lean ( ) ; } ;