Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [
- {
- "_id": "5cbabbd7545ac20f7c912e6a",
- "refno1": "REF1",
- "refno2": "REF2",
- "prodregdate": "2019-04-09T00:00:00.000Z",
- "data": [
- {
- "_id": "5cbabbd7545ac20f7c912e6b",
- "product": "5cb86b45cfafaa1860e29b2a",
- "serialno": "s123"
- },
- { // this data im not able to enter how to do it
- "_id": "5cbabbd7545ac20f7c912e6b",
- "product": "5cb86b45cfafaa1860e29b2a",
- "serialno": "s123"
- },
- ],
- "customer": {
- "_id": "5c98bb0a42207b16d8fbd3cf",
- "customername": "Raghav Update"
- },
- "customertype": {
- "_id": "5c7a1a1d4913fa08ac75c027",
- "customertype": "Government "
- },
- "__v": 0
- }
- ]
- const mongoose = require('mongoose');
- const Schema = mongoose.Schema;
- const ProductRegistrationSchema = new Schema({
- //Product Details
- _id: { type: mongoose.Schema.Types.ObjectId },
- refno1: { type: String },
- refno2: { type: String },
- data: [{
- product: {
- type: mongoose.Schema.Types.ObjectId,
- ref: "product"
- },
- //DATES
- //OEM
- oemwarrantyfrom: { type: Date },
- oemwarrantyto: { type: Date },
- //SERVICE PROVIDER
- warrantyfrom: { type: Date },
- warrantyto: { type: Date },
- serialno: { type: String },
- }],
- prodregdate: { type: Date },
- //Details of Customer buying the product
- customer: {
- type: mongoose.Schema.Types.ObjectId,
- ref: "customer"
- },
- customertype: {
- type: mongoose.Schema.Types.ObjectId,
- ref: "customertype"
- },
- department: {
- type: mongoose.Schema.Types.ObjectId,
- ref: "customersubdepartment"
- },
- remarks: { type: String },
- entrydate: {
- type: Date,
- dafault: Date.now
- }
- module.exports = ProductRegistration = mongoose.model('productregistration', ProductRegistrationSchema);
- const express = require('express');
- const router = express.Router();
- const mongoose = require('mongoose');
- const Product = require("../../../models/Master/Products");
- //importing the model of ProductRegistrationSchema
- const ProdReg = require('../../../models/Entries/ProductRegistration');
- //Creating a new ProductRegistration Data
- router.post('/add', (req, res)=>{
- const newProdReg = new ProdReg({
- _id: new mongoose.Types.ObjectId(),
- refno1: req.body.refno1,
- refno2: req.body.refno2,
- prodregdate: req.body.prodregdate,
- data: {
- product: req.body.productid,
- oemwarrantyfrom: req.body.oemwarrantyfrom,
- oemwarrantyto: req.body.oemwarrantyto,
- warrantyfrom: req.body.warrantyfrom,
- warrantyto: req.body.warrantyto,
- serialno: req.body.serialno,
- },
- customer: req.body.customerid,
- customertype: req.body.customertypeid,
- department: req.body.customersubdepartmentid,
- remarks: req.body.remarks
- // deliverydate: req.body.deliverydate,
- // address: req.body.address,
- // assignedto: req.body.employeesid,
- // warrantyprovider: req.body.serviceproviderid,
- // oemwarrantyprovider: req.body.oemcompanyid,
- // warrantystartdate: req.body.warrantystartdate,
- // warrantyexpiredate: req.body.warrantyexpiredate,
- });
- newProdReg.save().then(prodreg => res.json(prodreg));
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement