These are chat archives for Automattic/mongoose

21st
Mar 2016
Brian Veltman
@brianveltman
Mar 21 2016 13:29
Hello, is it possible to use upsert with mongoose for arrays? Currently I have newItem.save({upsert:true, new:true},function (err) { … }; But it creates all new items with empty strings while newItem is a array with all tje json objects i.e: all the items.
James Lee
@uptownhr
Mar 21 2016 14:51
@jhyland87 it will return a null
error will = null and response will = null
Wojtczyk
@awojtczyk
Mar 21 2016 15:41
This message was deleted

Hi there, how can i query by populated key value?
var ListItemSchema = new mongoose.Schema({ date:{ type: Date, default: Date.now }, postedBy: { type: mongoose.Schema.Types.ObjectId, ref: 'User' }, product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product' }, qty: { type: Number, max: 100 } });

and
var ProductSchema = new Schema({ name: {type: String,required: true, unique:true}, price: {type: String} });
I would really like do something like ListItem.findOne({postedBy: decodedToken._id, product.name:'test'})

Erinç Fırtına
@EricMcRay
Mar 21 2016 16:03
how can i populate not saved mongoose document??
var user = new User({name: test, group: id});
user.populate(‘group’, cb);
Erinç Fırtına
@EricMcRay
Mar 21 2016 16:43
how can i use virtual properties in virtual object?