Neo Hsu
Store and sync data with our NoSQL cloud database.
Data is synced across all clients in realtime, and remains available when your app goes offline
{
"users": {
"alovelace": {
"name": "Ada Lovelace",
"contacts": { "ghopper": true },
},
"ghopper": { ... },
"eclarke": { ... }
}
}
const admin = require('firebase-admin')
const serviceAccount = require('../keys/pg-firebase-49eba-firebase-adminsdk-cvj83-01c9129dd5')
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: 'https://pg-firebase-49eba.firebaseio.com',
})
const db = admin.database()
db.ref('words').push({
name: 'test',
data: ['http://www.google.com', 'http://www.google.com'],
team: {
name: 'team',
},
tag: [
{
type: '#',
name: 'test#',
}, {
type: '@',
name: 'test@',
}
]
})
const db = firebaseAdmin.database();
const ref = db.ref("dinosaurs");
ref.orderByChild("height").on("child_added", function(snapshot) {
console.log(snapshot.key + " was " + snapshot.val().height + " meters tall");
});
db.ref('/words').on('child_added', (snap) => {
console.log('added:', snap.key)
})
db.ref('/words').on('value', (data) => {
console.log(data.val())
})