Firebase中的对象很少:user
,attributes
和attributesValues
。
User
具有一个名为attributes
的属性,其值位于attributes
对象中。
因此,如果对象user
如下所示:
"user': {
"name": "John"
"attributes": {
"0": "2",
}
}
和attributes
对象看起来像这样:
"attributes": {
"id": "0",
"lastName": "Doe"
}
attributesValues
对象如下:
"attributesValues": [
"valueOne|valueTwo|valueThree|valueFour|valueFive",
"typeOne|typeTwo|typeThree|typeFour|typeFive",
"numberOne|numberTwo|numberThree|numberFour|numberFive",
"addressOne|addressTwo|addressThree|addressFour|addressFive"
]}
如何显示用户的姓氏? user.attributes.[0]
不起作用。
这是我的firebase文件: 从“ firebase”导入{initializeApp}
const app = initializeApp({
apiKey: 'apiKey',
authDomain: 'projectId.firebaseapp.com',
databaseURL: 'https://projectId.firebaseio.com',
projectId: 'projectId',
storageBucket: '',
messagingSenderId: 'messagingId',
appId: 'appId'
})
export const db = app.database()
export const usersRed = db.ref('users')
export const attributesRef = db.ref('attributes')
export const attributesValuesRef = db.ref('attributesValues')