0
const mongoose = require('mongoose')
const Schema = mongoose.Schema
let transactionSchema = new Schema({
userId: mongoose.SchemaTypes.ObjectId,
transactionDate: { type: Date, required: true },
transactionType: { type: String, required: true },
description: { type: String, required: true },
charge: { type: Number, default: 0 },
deposit: { type: Number, default: 0 },
notes: { type: String, default: '' },
createdOn: { type: Date, default: Date.now }
})
const Transaction = mongoose.model('Transaction', transactionSchema)
module.exports = Transaction
In the above code I understand that I am working on the model part because I have knowledge of MVC realize that I am monstando my database and ETC but what I do not realize is this excerpt:
const mongoose = require('mongoose')
It creates a constant ok but how does this require work ? Until where I realized it should fetch from my node_modules folder the files it needs to run correctly ? but how does it work exactly? know some documentation of this?