Skip to content

Instantly share code, notes, and snippets.

@chasestarr
Created October 24, 2017 02:58
Show Gist options
  • Save chasestarr/8cf133772846bb8cc9f44d26d9ba460e to your computer and use it in GitHub Desktop.
Save chasestarr/8cf133772846bb8cc9f44d26d9ba460e to your computer and use it in GitHub Desktop.
// model file
// is this a bad idea?
class Gig extends MongoModel {
/**
* extends the functionality of model update method
*
* @param {string} query - object to query db on
* @param {any[]} args - arguments to forward to parent class update
*/
update(query: Object, ...args: any[]) {
console.log('id', query._id);
return super.update(query, ...args);
}
/**
* extends the functionality of model findOneAndUpdate method
*
* @param {string} id - gig id to find
* @param {any[]} args - arguments to forward to parent class update
*/
findOneAndUpdate(query: Object, ...args: any[]) {
console.log('id', query._id);
return super.findOneAndUpdate(Object, ...args);
}
/**
* extends the functionality of model findByIdAndUpdate method
*
* @param {string} id - gig id to find
* @param {any[]} args - arguments to forward to parent class update
*/
findByIdAndUpdate(id: string, ...args: any[]) {
console.log('id', id);
return super.findByIdAndUpdate(id, ...args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment