0

I'm trying to make a played command (if any of you have used it on tatsu, now deprecated)

I'm trying to add games into a firebase database, but I am unable to name it correctly.

The code is:

let currentname = (m.game.name).toString()
db.collection('bde').doc(m.id).get().then((q) => {
  if (!q.exists) {
    db.collection('bde').doc(m.id).set({

    })
  }
  db.collection('bde').doc(m.id).update({
    currentname
  }).then(
    console.log('wrote')
  )
})

The part let currentname = (m.game.name).toString(), gets the name of the current game, but when put into the DB, it saves like:

currentName: "Visual Studio Code"

It inputs as currentname: "Visual Studio Code", I need it to input as [whatever the game is]: 'time'

I am unable to put m.game.name, as it does this.

https://media.discordapp.net/attachments/712144167656226866/750477983168593980/unknown.png

Please let me know if you know a solution to this.

GirkovArpa
  • 4,427
  • 4
  • 14
  • 43
  • And if you log currentName before writing it to Firestore? Firestore isn't going to change the string, so "Visual Studio Code" is certainly exactly what you have in that string. – Doug Stevenson Sep 01 '20 at 23:09
  • Where is `m.game.name` used? I doubt you need to convert `toString`. Where are you trying to use m.game.name? It appears in the screenshot you're trying to pass it into an object... I'm guessing you'll need to set `currentName: m.game.name` – Phix Sep 01 '20 at 23:15
  • Firebase is the changing it, it's the way it's being put in. It logs as Visual Studio Code. This is what it looks like on Firebase: https://i.imgur.com/LMJrhoo.png –  Sep 01 '20 at 23:23
  • Hi @Bee could you please print the value of the `m.game.game` before setting it into Firestore? As mentioned before, Firestore **doesn't** change values, it only adds to the database the value that you have in your string. So, it seems that you are not returning the value correctly, beforing sending it to Firestore. – gso_gabriel Sep 02 '20 at 12:56
  • Yes, I did print it before. It's the correct game name. It console.log()s Visual Studio Code (or any other game), but does not input with that name. As stated it inputs as currentname: "Visual Studio Code" –  Sep 02 '20 at 15:24
  • Console.log: https://i.imgur.com/a11dbkl.png Firebase: https://i.imgur.com/MFH2cY3.png Let me know if you'd like me to print or show anything else. –  Sep 02 '20 at 16:59
  • 1
    Considering that, I would recommend you to reach out to [Firebase support](https://firebase.google.com/support) directly, so they can investigate this further. – gso_gabriel Sep 08 '20 at 13:17

0 Answers0