These are chat archives for Automattic/mongoose

28th
Jun 2017
Artyom Tsurkan
@artsurkan
Jun 28 2017 09:36
hi! How make 1 default image with kind: 'thumbnail' and url:'https://blalblabla' ???
const Images = new Schema({
kind: {
        type: String,
        enum: ['thumbnail', 'detail'],
        required: false
    },
    url: {
        type: String
    },
});

const Tags = new Schema({
    label: {
        type: String
    },
});

const ArticleScheme = new Schema({
    images: [Images],
    title: {type: String, required: true},
    author: {type: String, required: true},
    text: {type: String, required: true},
    views: {
        type: Number,
        default: 123
    },
    tags: [Tags],
    createdAt: {
        type: Date
    }
});
Nesara
@NesarHD
Jun 28 2017 12:01
var cursor = this.find(query).select({
"alias": 1,
"To": 1,
"city": 1,
"state": 1,
"cdr": 1,
"RecordUrl": 1,
"From": 1,
"Digits": 1,
"bundle": 1,
"callResult": 1,
"advivrDuration": 1,
"connectDuration": 1,
"Duration": 1,
"StartTime": 1,
"comment": 1,
"zipcode": 1,
}).sort({ StartTimeNumberEST: -1 }).hint({ StartTimeNumberEST: 1 }).lean().cursor();
Previously it was this query now its the below one
var cursor = this.find(query).select({
"alias": 1,
"To": 1,
"city": 1,
"state": 1,
"cdr": 1,
"RecordUrl": 1,
"From": 1,
"Digits": 1,
"bundle": 1,
"callResult": 1,
"advivrDuration": 1,
"connectDuration": 1,
"Duration": 1,
"StartTime": 1,
"comment": 1,
"zipcode": 1,
"cpa": 1
}).sort({ StartTimeNumberEST: -1 }).hint({ StartTimeNumberEST: 1 }).lean().cursor();
the problem m facing is after adding cpa to be added to data cpa is always the default value
it does not send me the exact value in the database
pretty ne to mongo db anybody plz help
*new
Ben Chiciudean
@benydc
Jun 28 2017 18:36
Hi guys, how do I add the receiver object to the receivers array:
            async.forEach(receivers, function (receiver, callback) {
                User.findOne({
                    _id: receiver._id
                }, {
                        phone: 1,
                        picture: 1
                    }).populate("").sort('').exec(function (err, user) {
                        newPaperplane.receivers.push(user);
                        log.info('MQTT Publish');
                        mqttClient.publish('paperplane/' + receiver, JSON.stringify(newPaperplane));
                        callback();
                    });
            }, callback);