Skip to content

Instantly share code, notes, and snippets.

@tothandras
Last active October 25, 2018 11:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save tothandras/c2250afab25b54e83c55 to your computer and use it in GitHub Desktop.
Save tothandras/c2250afab25b54e83c55 to your computer and use it in GitHub Desktop.
user.js
import mongoose from 'mongoose';
const UserSchema = new mongoose.Schema({
name: {
type: String
},
age: {
type: Number,
index: true
},
createdAt: {
type: Date,
default: Date.now()
},
friends: [
{
type: mongoose.Schema.Types.ObjectId,
ref: 'User'
}
]
});
const User = mongoose.model('User', UserSchema);
export default User;
@Steveteile
Copy link

01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment