1const userSchema = mongoose.Schema({
2 email: String
3}, { timestamps: true });
1const mongoose = require('mongoose');
2
3const UserSchema = new mongoose.Schema({
4 name: {
5 type: String,
6 required: true
7 }
8}, {
9 timestamps: true
10})
11
12const User = mongoose.model('User', UserSchema);
13
14module.exports = User;
1var mongoose = require('mongoose');
2
3var UserSchema = new mongoose.Schema({
4 username: String,
5 email: String,
6 bio: String,
7 image: String,
8 hash: String,
9 salt: String
10}, {timestamps: true});
11
12mongoose.model('User', UserSchema);
13
1 var mongoose = require('mongoose');
2 var Schema = mongoose.Schema;
3
4 var blogSchema = new Schema({
5 title: String, // String is shorthand for {type: String}
6 author: String,
7 body: String,
8 comments: [{ body: String, date: Date }],
9 date: { type: Date, default: Date.now },
10 hidden: Boolean,
11 meta: {
12 votes: Number,
13 favs: Number
14 }
15 });
1 import mongoose from 'mongoose';
2 const { Schema } = mongoose;
3
4 const blogSchema = new Schema({
5 title: String, // String is shorthand for {type: String}
6 author: String,
7 body: String,
8 comments: [{ body: String, date: Date }],
9 date: { type: Date, default: Date.now },
10 hidden: Boolean,
11 meta: {
12 votes: Number,
13 favs: Number
14 }
15 });
16