Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inserting Weird Values After Updating #153

Open
mxnmike opened this issue Dec 19, 2022 · 0 comments
Open

Inserting Weird Values After Updating #153

mxnmike opened this issue Dec 19, 2022 · 0 comments

Comments

@mxnmike
Copy link

mxnmike commented Dec 19, 2022

When I do an Update on my Document, it inserts some weird values....

`function compareDB() {
const firestore = getFireStore()
const prodDB = firestore.query("ProTips").OrderBy("id").Execute()
const stagingDB = firestore.query("ProTipsStaging").OrderBy("id").Execute()

for (var x = 0; x < prodDB.length; x++) {
const prod = prodDB[x]
const staging = stagingDB[x]
if ((prod.fields.id['integerValue'] === staging.fields.id['integerValue']) &&
(prod.fields.id_pro['integerValue'] !== staging.fields.id_pro['integerValue'] ||
prod.fields.pro_tip_text['stringValue'] !== staging.fields.pro_tip_text['stringValue'] ||
prod.fields.date_published['timeStampValue'] !== staging.fields.date_published['timeStampValue'])) {
// console.log('prod name:', prod.name)
const splittedName = prod.name.split('/')
const slicedName = splittedName.slice(-2)
console.log(slicedName)
const documentURL = ${slicedName[0]}/${slicedName[1]}/

  prod.fields = staging
  prod.fields.updated = true
  console.log("Updated Tip:", prod.fields)
  console.log('DocumentURL:', documentURL)
  const updatedProTip = firestore.updateDocument(documentURL, prod, ["id_pro","pro_tip_text","date_published"], true)
  console.log(updatedProTip)
}

}
// console.log(prodDB)
}`

This is how it looks my firebase document before and after the update
BEFORE:
Screenshot 2022-12-18 at 4 06 04 p m

AFTER:
Screenshot 2022-12-18 at 4 06 42 p m

Any Idea of why is this happening??

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant