set notif if service your province
This commit is contained in:
45
src/server/models/search.js
Executable file
45
src/server/models/search.js
Executable file
@@ -0,0 +1,45 @@
|
||||
const mongoose = require('mongoose').set('debug', false)
|
||||
const Schema = mongoose.Schema;
|
||||
|
||||
mongoose.Promise = global.Promise;
|
||||
mongoose.level = "F";
|
||||
|
||||
const tools = require('../tools/general');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
|
||||
// Resolving error Unknown modifier: $pushAll
|
||||
mongoose.plugin(schema => {
|
||||
schema.options.usePushEach = true
|
||||
});
|
||||
|
||||
const searchSchema = new Schema({
|
||||
idapp: {
|
||||
type: String,
|
||||
},
|
||||
userId: {
|
||||
type: String,
|
||||
},
|
||||
text: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
searchSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp, sall) {
|
||||
const Search = this;
|
||||
|
||||
let myfind = {};
|
||||
if (sall === '1')
|
||||
myfind = { idapp };
|
||||
else
|
||||
myfind = { userId, idapp };
|
||||
|
||||
return Search.find(myfind, (err, arrsearch) => {
|
||||
return arrsearch
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const Search = mongoose.model('Search', searchSchema);
|
||||
|
||||
module.exports = { Search };
|
||||
Reference in New Issue
Block a user