Skip to content

Instantly share code, notes, and snippets.

@Anderson-Juhasc
Last active March 20, 2018 03:18
Show Gist options
  • Save Anderson-Juhasc/a41817fbf58503dfde40f95734acce91 to your computer and use it in GitHub Desktop.
Save Anderson-Juhasc/a41817fbf58503dfde40f95734acce91 to your computer and use it in GitHub Desktop.
const find = ( Model ) => ( query, sort = {} ) =>
Model.find({}).or( query ).sort( sort ).exec()
const findOne = ( Model ) => ( query, populate = '' ) =>
Model.findOne( query ).populate( populate ).exec()
const count = ( Model ) => ( query ) =>
Model.count( query ).exec()
const save = ( Model ) =>
Model.save().then()
const test = async () => {
let user = await findOne( UserModel )( { email: email } )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment