Last active
January 3, 2018 14:48
-
-
Save msfidelis/232f847210ff4986a4d81caac6231bd4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const ProductSchema = require('../models/Products'); | |
const ProductService = { | |
createProduct : productValues => { | |
return new ProductSchema(productValues).save(); | |
}, | |
updateProduct : (id, productValues) => { | |
return ProductSchema.findByIdAndUpdate(id, {$set: productValues}, {new: true}); | |
}, | |
findProductById: id => { | |
return ProductSchema.findOne({_id: id}); | |
}, | |
searchProductsWithPagination : (query = {}, paginationOptions = {}) => { | |
return ProductSchema.paginate(query, paginationOptions); | |
}, | |
deleteProductById : id => { | |
return ProductSchema.remove({_id: id}); | |
} | |
} | |
module.exports = ProductService; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment