flamelink / flamelink-js-sdk

🦊 Official Flamelink JavaScript SDK for both the Firebase Realtime database and Cloud Firestore
https://flamelink.github.io/flamelink-js-sdk
MIT License
43 stars 5 forks source link

ReferenceError: Property 'entryId' doesn't exist #117

Closed Nsingh13 closed 4 years ago

Nsingh13 commented 4 years ago

I'm trying to update a user schema entry. I did 'getByField' first in order to retreive the id of the entry. However when I run .update(), it returns an error saying "ReferenceError: Property 'entryId' doesn't exist"

flameLinkApp.content.getByField({ schemaKey: 'users', field: 'user.firstName', value: 'Test' }).then((data) => { console.log(data); let thisUserId = ''; for(let id in data) { thisUserId = id; console.log(thisUserId); } flameLinkApp.content.update({ schemaKey: 'users', entryId: thisUserId, data: { user: { firstName: 'Test complete' } } }).then(() => { console.log('User updated: '+entryId); }).catch((error) => { console.log('update error: '+error) }); });

Nsingh13 commented 4 years ago

Sorry, I tried to format the code so it's easier to read but I'm having issues. I'm fairly new to Github.

Nsingh13 commented 4 years ago

flameLinkApp.content.getByField({ schemaKey: 'users', field: 'user.firstName', value: 'Test' }).then((data) => { console.log(data); let thisUserId = ''; for(let id in data) { thisUserId = id; console.log(thisUserId); } flameLinkApp.content.update({ schemaKey: 'users', entryId: thisUserId, data: { user: { firstName: 'Test complete' } } }).then(() => { console.log('User updated: '+entryId); }).catch((error) => { console.log('update error: '+error) }); });

Nsingh13 commented 4 years ago

Fixed. Needed to replace 'entryId' in .then with thisUserId.