Closed acerov closed 9 years ago
This might very well be true.
Actually, this implemented by Ember Data itself. The localforage adapter just implements this method. If you want to have your own generator (e.g. uuid), then you can overload the generateIdForRecord
method.
import LFAdapter from 'ember-localforage-adapter/adapters/localforage';
export default LFAdapter.extend({
generateIdForRecord: function(store, inputProperties) {
var id = 'your id generation here';
return id;
}
});
Thnx, actually I do not want to replace generateIdForRecord just to bypass it when id is already set through setProperties, it is fine for me to be generated when id is not set. Hope I do not ask too much :)
I tried to implement generateIdForRecord in a way that when id is set then keep that id otherwise generate uuid but am facing this https://github.com/emberjs/data/issues/2516 and cannot access already set id. I use ember-data 1.13.8 Do you know some better way to accomplish this?
@acerov If I lookup the line where generateIdForRecord
is called in ED, it seems that now three arguments are passed. First the store
, second the modelName
and third the properties
.
If I am right, I would appreciate if you create a PR with a documentation update, because this doc is then out-of-date.
@frederikbosch yes I saw that but third argument, console.log(properties) gives me just Object {}
In that case I'd ask to reopen that issue. Or, even better, create a PR that solves it.
I ended up using push method which is more appropriate for my case which is to store locally records that exist on server.
Sounds logical to me!
Hi,
I am probably missing something but I cannot save record with my own integer id, it is always replaced with hash generated by localForage.