I am not a pro in JS/NodeJS and I have some experience using express-mongoose.
Now, I prefer MVC approach, meaning creating schema and importing it.
Since, Firebase database also happens to be no sql database, I decided on doing exactly what I am suppose to do in mongoose but unfortunately I am unable to understand.
To say the least, I have created index.js which is my entry point of the app.
And as per firebase docs, I am initialising it like this (index.js)
const admin = require("firebase-admin");
//Firbade config file
const firebaseConfig = require("./functions-config.json")
admin.initializeApp({
credential: admin.credential.cert(firebaseConfig),
databaseURL: "https://functions-firebase-43a59.firebaseio.com"
})
const db = admin.firestore()
.
Question: Can we create schema in firebase db as we are used to creating in mongoose
i.e this is the example of creating mongoose schema in NodeJS (models/user.js)
const mongoose = require('mongoose')
const userSchema = new mongoose.Schema({
fullName: String,
email: String,
image: String,
gender: String,
profile_id: String,
createdAt: {type: Date, default: Date.now}
})
module.exports = mongoose.model('User', userSchema);