schema mongoose
const fruitSchema = new mongoose.Schema ({
name: {
type: String
},
rating: {
type: Number,
min: 1,
max: 10
},
review: String
});
schema mongoose
const fruitSchema = new mongoose.Schema ({
name: {
type: String
},
rating: {
type: Number,
min: 1,
max: 10
},
review: String
});
mongoose schema
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var blogSchema = new Schema({
title: String, // String is shorthand for {type: String}
author: String,
body: String,
comments: [{ body: String, date: Date }],
date: { type: Date, default: Date.now },
hidden: Boolean,
meta: {
votes: Number,
favs: Number
}
});
mongoose sample schema
import mongoose from 'mongoose'
const { Schema } = mongoose
const value = {
type: String,
required: true,
trim: true,
unique: false
}
const UserSchema = new Schema({
fname: value,
lname: value,
email: {
type: String,
required: true,
trim: true,
unique: true
}
}, {
timestamps: true,
get: v => v.toDateString()
})
const User = mongoose.model('User', UserSchema)
export default User
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us