Creazione tabella Product

This commit is contained in:
Paolo Arena
2020-12-21 02:16:42 +01:00
parent 9ee59c0fc1
commit 67d2872e61
21 changed files with 767 additions and 42 deletions

30
src/server/models/category.js Executable file
View File

@@ -0,0 +1,30 @@
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
mongoose.Promise = global.Promise;
mongoose.level = "F";
// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
schema.options.usePushEach = true
});
const CategorySchema = new Schema({
name: {
type: String,
unique: true,
index: true,
lowercase: true
}
});
module.exports.getAllCategories = function (callback) {
Category.find(callback)
}
module.exports.getCategoryById = function (id, callback) {
Category.findById(id, callback);
}
module.exports = mongoose.model('Category', CategorySchema);