I'm using firebase real-time database with express.js as backend. Here's my data saving snippet code:
const db = require('./firebase_connection').firebaseDatabase
async function saveData(req, model) {
await db.ref(model).set(req)
return {"statusCode": "201", "message": "Inserted successfully"}
}
module.exports = { saveData }
This is the json output:
{
"user" : {
"email" : "TEST77@TEST.com",
"full_name" : "Hossein Heydari",
"password" : "test",
"phone_number" : 54,
"role" : "client"
}
}
But I also need an Id added to database automatically, just like what MongoDB
has which is _id
I need firebase to store data with a auto increment Id for any model, what should I do?