Node Js Firestore accessing a database value with

2019-08-18 05:58发布

new to node Js expecting this to be very easy!

in node JS with Firestore i want to access "display name": James, "Age": 22

Age has no space so i can just put

const newValue = doc.data();
             const age = newValue.Age;

but display name contains a space how to you type this?

 const displayName = newValue.displayName;

1条回答
混吃等死
2楼-- · 2019-08-18 06:38

You'll need to use [] notation to get at the property.

So:

const displayName = newValue["display name"];
查看更多
登录 后发表回答