copleykj / socialize-base-model

MIT License
14 stars 12 forks source link

Failing to save model when _id passed on constructor #1

Closed Fabs closed 9 years ago

Fabs commented 9 years ago

There was, I believe, a typo on the this.collection when you tried to save a model that had previously received an _id.

copleykj commented 9 years ago

You're right, thanks for the catch

Fabs commented 9 years ago

Also, when I fixed that, I started getting MongoError: Modifiers and non-modifiers cannot be mixed.

I think maybe the full correction would be: this._collection.upsert(this._id, {$set: this});

I don't realy get why this, maybe it has something to do with how it uses $setOnInsert internally?

copleykj commented 9 years ago

Yes, I've actually changed this to an update now. It makes sense as it's doing an insert when there isn't an _id

Fabs commented 9 years ago

Nice, thanks.