DEV Community

loading...

#3 Models and Collection

rittwickbhabak profile image Rittwick Bhabak ・1 min read

File: models/marioChar.js

const mongoose = require('mongoose');

const Schema = mongoose.Schema;

const MarioCharSchema = new Schema({
    name: String,
    weight: Number
})

const MarioChar = mongoose.model('mariochar', MarioCharSchema)

module.exports = MarioChar;

// Now we can do the following
// var myChar = new MarioChar({ name: "Rayan", weight: 100 });
Enter fullscreen mode Exit fullscreen mode

Discussion

pic
Editor guide