PDA

View Full Version : model.set() is not changing my record (as far as store is concerned)



dcoan604
21 Feb 2012, 2:12 PM
I have a model with 'id' as the primary key.
There is another field in my model called 'contact_id' ... which is the primary key of another table,
However, this foreign key is NOT defined as a foreign key in my model.
Nor have I used any BelongsTo or HasMany associations.


Yet, if I create a new instance of the model (as a phantom with no primary key) and then use:
myRecord.set({contact_id: xxxx}), and then add this record into my store....
the model doesn't show up in myStore.getUpdatedRecords() or myStore.getNewRecords()


Why?

Shouldn't it show up in BOTH? it is new (has no primary key set).... and is updated (I changed one of its values since it was instantiated).

HMM... quick edit here: I just noticed that if I removed all validation definitions in my model.... then it would show up in getNewRecords()

so, getNewRecords is actually working as getNewVALIDRecords which is fine I guess....
Does someone have a getInvalidRecords() function written?

mitchellsimoens
21 Feb 2012, 7:01 PM
getInvalidRecords but you don't have any validations anymore?

dcoan604
21 Feb 2012, 11:20 PM
Removing the validations was just a test.

It would be cool if you could pass Booleans to getUpdatedRecords and getNewRecords like

Store.getUpdatedRecords(includeNew)
store.getNewRecords(includeInvalid)

Basically, I just want to remove all changes made to the store, withou reloading it.

Is there a better way that I have missed?