60 lines
1006 B
JavaScript
60 lines
1006 B
JavaScript
const mongoose = require('mongoose');
|
|
const Schema = mongoose.Schema;
|
|
|
|
mongoose.Promise = global.Promise;
|
|
mongoose.level = "F";
|
|
|
|
const { ObjectID } = require('mongodb');
|
|
|
|
// Resolving error Unknown modifier: $pushAll
|
|
mongoose.plugin(schema => {
|
|
schema.options.usePushEach = true
|
|
});
|
|
|
|
const sendmsgSchema = new Schema({
|
|
idapp: {
|
|
type: String,
|
|
},
|
|
userId: {
|
|
type: String,
|
|
},
|
|
idappDest: {
|
|
type: Number,
|
|
},
|
|
usernameDest: {
|
|
type: String,
|
|
},
|
|
msg: {
|
|
type: String,
|
|
},
|
|
date: {
|
|
type: Date,
|
|
},
|
|
read: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
deleted: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
originpage: {
|
|
type: String,
|
|
},
|
|
|
|
});
|
|
|
|
sendmsgSchema.statics.findAllByUserIdAndIdApp = function (userId, idapp) {
|
|
const SendMsg = this;
|
|
|
|
return SendMsg.find({userId, idapp}, (err, arrmsg) => {
|
|
console.log('ris arrmsg:', arrmsg);
|
|
return arrmsg
|
|
});
|
|
};
|
|
|
|
|
|
var SendMsg = mongoose.model('SendMsg', sendMsgSchema);
|
|
|
|
module.exports = { SendMsg };
|