Skip to content
Snippets Groups Projects

Sell 기능 (일부) 추가

Merged LeeYongJae requested to merge sell_YJ into master
13 files
+ 354
157
Compare changes
  • Side-by-side
  • Inline
Files
13
+ 41
31
var mongoose = require('mongoose');
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
var autoInc = require("mongoose-auto-increment");
const BookSchema = mongoose.Schema({
title: {typr :String},
grade: { type: Number },
major: { type: String},
type: { type: String},
src: { type: String},
seller :[{
seller_id: { type: String},
on_transaction : {type: Boolean}
}],
stock: {type: Number}
const BookSchema = new Schema({
_id: { type: Number },
title: { type: String },
grade: { type: Number },
major: { type: String },
type: { type: String },
src: { type: String },
seller: [
{
seller_id: { type: String },
on_transaction: { type: Boolean }
}
],
stock: { type: Number }
});
BookSchema.statics.create = function(Book_info) {
const {
title,
grade,
major,
type,
src,
} = Book_info;
const {
title,
grade,
major,
type,
src,
stock,
seller: []
} = Book_info;
const Book = new this({
title,
grade,
major,
type,
src,
stock,
seller: []
});
// return the Promise
return Book.save();
};
const Book = new this({
title,
grade,
major,
type,
src,
})
// return the Promise
return Book.save()
}
autoInc.initialize(mongoose.connection);
BookSchema.plugin(autoInc.plugin, "Book");
module.exports = mongoose.model('Book', BookSchema);
\ No newline at end of file
module.exports = mongoose.model("Book", BookSchema);
Loading