You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
js-data-firebase works best when the key is part of the result set. If you use js-data-firebase to create records in firebase, then it will save the key to the result set for you. It looks like you may be loading items that were not created by js-data-firebase, and thus do not have the key in the result set.
Hi Jason,
You are right it is simpler as you suggest,
but my idea is to make hidden property idAttribute, and now going back to it, even i think is better to attach it to prototype of the value object not to value object itself, like that we don't need to copy key data also to the the node value.
Using Object.defineProperty is creating new property which is not writable, not enumerable and can't be deleted, that is my idea.
Mi Idea for creating a property on prototype is not working, so I'm going back to initial idea.
So i used Object.defineProperty just to add property attributes as i explained above. In plus we need to add check if the property already exist just not to overwrite it like:
if (!value.hasOwnProperty(mapper.idAttribute)) {
Object.defineProperty(value, mapper.idAttribute, {
value: key
})
}
Activity
jmdobry commentedon Sep 20, 2017
js-data-firebase works best when the key is part of the result set. If you use js-data-firebase to create records in firebase, then it will save the key to the result set for you. It looks like you may be loading items that were not created by js-data-firebase, and thus do not have the key in the result set.
Your suggestion of adding
seems like it would work, I look forward to your PR. However, couldn't it be simplified to
?
JovanT commentedon Sep 20, 2017
Hi Jason,
You are right it is simpler as you suggest,
but my idea is to make hidden property
idAttribute, and now going back to it, even i think is better to attach it toprototypeof thevalue objectnot tovalue objectitself, like that we don't need to copy key data also to the the node value.Using
Object.definePropertyis creating new property which is not writable, not enumerable and can't be deleted, that is my idea.my suggested code will look like this:
if you think it is fine and you agree Ill offer even to make the change and to begin as the js-data-firebase contributor, step by step :)
Best,
Jovan.
JovanT commentedon Sep 20, 2017
Mi Idea for creating a property on
prototypeis not working, so I'm going back to initial idea.So i used
Object.definePropertyjust to add property attributes as i explained above. In plus we need to add check if the property already exist just not to overwrite it like:Best,
Jovan.