Created
May 8, 2018 08:46
-
-
Save vietduchelo/a69132f6106f5665162e7d23c181168c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var mongoose = require('mongoose'); | |
var Schema = mongoose.Schema; | |
var bookSchema = new Schema({ | |
author: { | |
type: Schema.Types.ObjectId, | |
ref: 'user' | |
}, | |
title: { | |
type: String, | |
required: true | |
}, | |
description: { | |
type: String | |
} | |
}); | |
bookSchema.index({description: 'text', title: 'text'}); | |
var Book = mongoose.model('book', bookSchema); | |
module.exports = Book; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment