Answers for "what is schema in mongoose"

Go
3

mongoose schema

const productSchema = new Schema({
    name: { type: String, required: true },
    price: { type: String, required: true },
    size: { type: String, required: true },
    image: {
        type: String, required: true, get(image) {
            // http://localhost:5000/upload/imagename.png
            return `${APP_URL}/${image}`
        }
    },
}, { timestamps: true, toJSON: { getters: true }, id: false })
Posted by: Guest on March-11-2022
0

mongoose schema

// Define schema
var Schema = mongoose.Schema;

var SomeModelSchema = new Schema({
  a_string: String,
  a_date: Date
});

// Compile model from schema
var SomeModel = mongoose.model('SomeModel', SomeModelSchema );
Posted by: Guest on May-07-2021

Browse Popular Code Answers by Language