set notif if service your province

This commit is contained in:
Surya Paolo
2023-04-13 13:46:48 +02:00
parent cada7aa0b6
commit cda0bff21f
7 changed files with 136 additions and 35 deletions

45
src/server/models/search.js Executable file
View 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 };