I want the constructor of the model, to flag all attributes as changed if the model is new

Vadim Demedes

@vadimdemedes

if Post.find, model can't be new, because it is stored already

Matías Olivera

@olistic

so if I check in the changed attribute I can get the modified attributes, whether they have been modified or they are new

Vadim Demedes

@vadimdemedes

you can check if a property is new, if its previous value is undefined

Matías Olivera

@olistic

I will have to go in 5 minutes Vadim, maybe it would be better if I write you an email detailing the issue with more calm

Vadim Demedes

@vadimdemedes

yeah ok

Matías Olivera

@olistic

I think it worth mentioning that I would be pleased to help

in this or anything that comes up in the future

Rodrigo Espinosa

@RodrigoEspinosa

Hello everybody! Vadim, cheers for a such a great project, I was looking at the code today and it's super clean, really like it!

I think what @moliveraf was trying to said is that, in order to know if the new model instance comes from a .find, the constructor needs to check if the _id property is defined.

Rodrigo Espinosa

@RodrigoEspinosa

So, lets see, @moliveraf is proposing that the this.set(attrs) should be called from the constructor when the model instance is absolutely new and hasn't been saved yet, is that right @moliveraf ?This new behaviour is for populating the changed object before saving the instance.In that way, when I create a new model instance, every attribute will be flagged as changed until I save.

Matías Olivera

@olistic

That’s exactly what I want @RodrigoEspinosa

Callum Lyall

@BeachedCactus

Hi there! When I assign a ID before saving using ObjectId from mongorito.ObjectId it doesn't actually save but still passes. Any ideas? Thanks

@BeachedCactus Hey! Sorry for such a late reply. If you set ObjectId before first save, it assumes the document is already in the database, so it calls update() instead of insert(). I think that may be the problem.

Mathieu Ghennassia

@mathieug

Hello. I have troubles trying to chain mongorito.connect() in my promises chain.