repo for angularjs testing training
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

29 lines
587 B

var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var bookSchema = new Schema({
_id: {type: mongoose.Schema.ObjectId, auto: true},
__v: {type: Number, select: false},
title: String,
description: String,
author: String,
pageLength: Number,
publisher: String,
publicationDate: String
},
{
timestamps: true
});
bookSchema.virtual('id').get(function(){
return this._id.toHexString();
});
// Ensure virtual fields are serialised.
bookSchema.set('toJSON', {
virtuals: true
});
var Book = mongoose.model('Book', bookSchema);
module.exports = Book;