Dear webix team, i’d like to have your feeling regarding that.
- In mongodb, the “_id” field is static, we can not rename it.
- In webix datastores, it"s the “id” field which is static.
The most common way to change “_id” into “id” is to use a custom proxy, see change id to _id for rest backend - #3 by mettaworks
The problem is when you use this method, you have to loop on each record.
That’s not a problem if you don’t have huge data. But it can be a problem if you have a huge amount of data, causing browser CPU jumps, UI freezes.
I tried to find another way to do that, and perhaps i found one. Seem’s it make the job.
In top of my code, i’m overriding a Datastore.id prototype function
webix.DataStore.prototype.id = function (data) {
// let's see if we have a mongodb id
data.id = data._id || data.id;
// in the line below, uid() has been changed into webix.uid()
// because of the scope
return data.id || (data.id = webix.uid());
}
Below the original function we can find in the webix source code
webix.DataStore.prototype.id = function (data) {
return data.id || (data.id = uid());
}
That’s all. Just 2 lines changed.
I no longer need a proxy
Feedback from webix team, to ensure this hack as no effect side possible should be REALLY appreciated.