I’m a beginner with MongoDB and Mongoose.
I’m working with a node.js & expressjs web app, and i found a ‘models’ folder which contains the following files: ‘device.model.js’ and ‘index.js’.
I’m just wondering if this is standard for mongoose? Because I don’t know how to interpret the folder name and the file extension. (.model.js).
Inside device.model.js you have the follwing code:
export default class Device {
static db = null
constructor (data = {}) {
const { id = mUUID.v4().toString(), name, createdAt, updatedAt } = data
this.id = id
this.name = name
this.createdAt = createdAt
this.updatedAt = updatedAt
}
And then a bunch of functions.
I also don’t understand the constructor code, especially the parameter (what is it, an empty js object?) and this line of code:
const { id = mUUID.v4().toString(), name, createdAt, updatedAt } = data
If all of this isn’t Mongoose, then what are they working with?
Thank you.