2016-10-20 5 views
0

新しい文書レコードを保存しようとしていますが、一部のフィールドが省略されていて、その理由を把握できませんでした。すべてのフィールドを保存していません

ここで私はにconsole.logから私のためのオブジェクト

var obj = new Order(orderObj); 
console.log('orderObj', orderObj); 
console.log('obj', obj); 

出力設定しています:ここで

orderObj { customerId: '5806e2a1759fd9ad7a1f60eb', 
    products: 
    [ { productId: '5806e7e3d0073cb4d2946aad', 
     customerPrice: 100, 
     notes: 'test', 
     originalPrice: 99.95, 
     priceOverride: true } ], 
    notes: 'some optional order notes', 
    createdBy: 'test', 
    total: 99.95 } 

obj { customerId: 5806e2a1759fd9ad7a1f60eb, 
    notes: 'some optional order notes', 
    createdBy: 'test', 
    _id: 5808171e802121505e33b252, 
    shipped: false, 
    shippedDate: 2016-10-20T01:00:14.019Z, 
    status: 'Created, Not Shipped', 
    products: 
    [ { productId: 5806e7e3d0073cb4d2946aad, 
     _id: 5808171e802121505e33b253, 
     quantity: 1 } ] } 

は私のスキーマです:

var orderSchema = new mongoose.Schema({ 
    customerId: { type: mongoose.Schema.Types.ObjectId, ref: 'Customer'}, 
    products: [{ 
    productId: { type: mongoose.Schema.Types.ObjectId, ref: 'Product'}, 
    quantity: { type: Number, default: 1 }, 
    originalPrice: { Type: Number }, 
    customerPrice: { Type: Number }, 
    priceOverride: { Type: Boolean, default: false }, 
    notes: { Type: String } 
    }], 
    notes: String, 
    status: { type: String, default: "Created, Not Shipped" }, 
    orderDate: { type: Date }, 
    shippedDate: { type: Date, default: Date.now }, 
    shipped: { type: Boolean, default: false }, 
    total: {Type: Number, default: 0.00 }, 
    createdBy: { type: String } 
}, schemaOptions); 

をなぜ合計私が把握することはできませんし、 productフィールド(originalPrice、priceOverride)は、mongoose Schemaインスタンスオブジェクトから削除されます。

答えて

0

もちろん、私はこの質問を投稿した直後に考え出しました。スキーマの型は、型の代わりに型としてリストされていました。

関連する問題