These are chat archives for Automattic/mongoose

24th
Jun 2017
Ben Chiciudean
@benydc
Jun 24 2017 10:09
Can someone help me with populate?
Ben Chiciudean
@benydc
Jun 24 2017 10:17
this is my schema:
module.exports = mongoose.model('User', new Schema({
    gender : String,
    email : String,
    token : String,
    firstname : String,
    lastname : String,
    picture : {type : String, required : true, default : "/default-user.jpg"},
    phone : String,
    city : String,
    address : String,
    postcode : String,
    description : String,
    device_id : String,
    push_token : String,
    code : String,
    is_activated : {type : Boolean, default : false},
    contacts : [{type : Schema.Types.ObjectId, ref : "User"}],
}));
And I want to return only picture, _id and phone:
User.findOne({ phone: req.query.phone }).populate("", ['_id', 'phone', 'picture']).sort('').exec(function (err, user) {})
Ben Chiciudean
@benydc
Jun 24 2017 11:52
I found how to do it
Matthew Pengelly
@mcpengelly
Jun 24 2017 12:40
hey guys ive got a mongo database that im using mongoose to perform operations on
i want to insert a large amount of data (ie: couple million records) in the database but most of the methods i have tried throw an error like: Bulk operations not supported
does anyone know a way around this?