These are chat archives for Automattic/mongoose

Dec 2016
Alex Budin
Dec 18 2016 07:42
can someone please help me with an unique question :)
i have a schema for an user. i have the user_id field defined with unique:true and dropDups: true
everytime i save
works fine the first time, but the second time it throws the error: MongoError: E11000 duplicate key error collection: charades.users index: user_id_1 dup key:
how can i avoid this?
i want the save to be executed, but nothing to get saved if the user_id exists
Alex Budin
Dec 18 2016 07:49
just that i dont want to do do a find before the save, im expecting mongo just to ignore if it still exists
Tobias Lundgren
Dec 18 2016 18:06
Hi! I have the same question as kiran I think. I have an collection called Customer and one called CustomerAddons. This two must be separated. But I would like to get query with all customers including the CustomerAddons fields in the easiest and fastest way. Customer { CardCode: String, …} CustomerAddons { customerId: String , … } So for each Customer i want to add CustomerAddons.customerId = Customer.CardCode. Or if it’s better to get the Customer data ion the CustomerAddons field. Please help me :)