Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vietduchelo/a69132f6106f5665162e7d23c181168c to your computer and use it in GitHub Desktop.
Save vietduchelo/a69132f6106f5665162e7d23c181168c to your computer and use it in GitHub Desktop.
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