공부 방식을 바꾸기로 했다.
걍의를 무작정 듣는 것보다 출력이 중요하다.
강의를 들으면서 기록하지 않고 강의를 끝까지 들은 후 강의의 내용을 기억해내서 적어보기
📙 코딩 2시간 + 인적성 수리+추리 영역 8시간
👍🏼 -
👎🏼 -
//in product.js
//스키마는 name, price, category
//farm과 연결할 것
const mongoose = require('mongoose');
const { Schema } = mongoose.Schema;
const productSchema = new Schema({
name: {
type: String,
required: true,
},
price: {
type: Number,
required: true,
min: 0,
},
category: {
type: String,
lowercase: true,
enum: ['fruit', 'vegetable', 'dairy'],
},
farm: {
type: Schema.Types.ObjectId,
ref: 'Farm',
},
});
const Product = mongoose.model('Product', productSchema);
module.exports = Product;
//in farm.js
//스키마는 name, city, email - name과 city는 required 아니면 메시지 나오게
//product와 연결할 것
const mongoose = require('mongoose');
const { Schema } = mongoose.Schema;
const farmSchema = new Schema({
name: {
type: String,
required: [true, 'Farm must have a name'],
},
city: {
type: String,
},
email: {
type: String,
required: [true, 'Email required'],
},
product: {
type: Schema.Types.ObjectId,
ref: 'Product',
},
});
const Farm = new mongoose.model('Farm', farmSchema);
module.exports = Farm;
//in product.js
//스키마는 name, price, category
//farm과 연결할 것
const mongoose = require('mongoose');
const { Schema } = mongoose.Schema;
const productSchema = new Schema({
name: {
type: String,
required: true,
},
price: {
type: Number,
required: true,
min: 0,
},
category: {
type: String,
lowercase: true,
enum: ['fruit', 'vegetable', 'dairy'],
},
farm: {
type: Schema.Types.ObjectId,
ref: 'Farm',
},
});
const Product = mongoose.model('Product', productSchema);
module.exports = Product;
//in farm.js
//스키마는 name, city, email - name과 city는 required 아니면 메시지 나오게
//product와 연결할 것
const mongoose = require('mongoose');
const { Schema } = mongoose.Schema;
const farmSchema = new Schema({
name: {
type: String,
required: [true, 'Farm must have a name'],
},
city: {
type: String,
},
email: {
type: String,
required: [true, 'Email required'],
},
product: {
type: Schema.Types.ObjectId,
ref: 'Product',
},
});
const Farm = new mongoose.model('Farm', farmSchema);
module.exports = Farm;