xavierlacot / joli.js

joli.js is an Activerecord-like javascript ORM, particularly suited for being used in the Appcelerator Titanium Mobile framework.
MIT License
267 stars 60 forks source link

For bulk values setting instead of using set in a loop #45

Open antongorodezkiy opened 9 years ago

antongorodezkiy commented 9 years ago

First I tried to use .fromArray() but after some struggle I understood, that if I'll use .fromArray(), the .isChanged() will be always false. So I propose to create separate method for setting some array/object at once instead of using .set() in a loop.

Example:

var record = Alloy.Globals.models.some_records.findOneBy('id', current.id);
record.setFromArray(current);
record.save();