no message
This commit is contained in:
@@ -3,10 +3,10 @@ const Logger = require('../modules/logger');
|
||||
const Mongoose = require('mongoose');
|
||||
|
||||
const MessageSchema = new Mongoose.Schema({
|
||||
"order" : { type: Number, default: 0 },
|
||||
"text" : { type: String },
|
||||
"image" : { type: String, index: true },
|
||||
"isUser" : { type: Boolean, default: false, required: true, index: true }
|
||||
"isUser" : { type: Boolean, default: false, required: true, index: true },
|
||||
"timestamp": { type: Date, default: Date.now() }
|
||||
});
|
||||
|
||||
MessageSchema.pre('findOneAndUpdate', function (next) {
|
||||
|
||||
@@ -23,7 +23,7 @@ const ProfileSchema = new Mongoose.Schema({
|
||||
"weight": { type: Number },
|
||||
"status": [{ type: String, enum: ['unknown','negative','negative, on prep','postive','positive, undetectable'] }],
|
||||
"tested": { type: Date },
|
||||
"tribe": [{ type: String, enum: [] }]
|
||||
"tribe": [{ type: String, enum: ['twink','geek','otter','bear','daddy','jock'] }]
|
||||
},
|
||||
"messages" : [ { type: Messages.schema } ]
|
||||
});
|
||||
@@ -139,8 +139,8 @@ module.exports = {
|
||||
.sort({ order: 1 })
|
||||
.populate({
|
||||
path: 'messages',
|
||||
select: 'order text image isUser',
|
||||
options: { sort: { order: 1 } }
|
||||
select: 'text image isUser timestamp',
|
||||
options: { sort: { timestamp: 1 } }
|
||||
})
|
||||
.exec((err, result) => {
|
||||
if (err) {
|
||||
@@ -163,7 +163,15 @@ module.exports = {
|
||||
|
||||
allMessages: (e, profileId) => {
|
||||
const promise = new Promise((resolve, reject) => {
|
||||
ProfileModel.findById(profileId, (err, result) => {
|
||||
ProfileModel
|
||||
.find({ _id: profileId })
|
||||
.select('messages')
|
||||
.populate({
|
||||
path: 'messages',
|
||||
select: 'text image isUser timestamp',
|
||||
options: { sort: { timestamp: 1 } }
|
||||
})
|
||||
.exec((err, result) => {
|
||||
if (err) {
|
||||
reject(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user