SHARE
TWEET

Untitled

a guest Aug 14th, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import mongoose from "mongoose";
  2. import { ObjectID } from "mongodb";
  3.  
  4. const Schema = mongoose.Schema;
  5.  
  6. ObjectID.prototype.valueOf = function() {
  7.   return this.toString();
  8. };
  9.  
  10. const CompanySchema = new Schema(
  11.   {
  12.     name: {
  13.       type: String,
  14.       unique: true,
  15.       required: true
  16.     },
  17.     logo: {
  18.       type: String,
  19.       unique: true,
  20.       required: true
  21.     },
  22.     level: {
  23.       type: Number,
  24.       default: 0
  25.     },
  26.     freights: [
  27.       {
  28.         type: Schema.Types.ObjectId,
  29.         ref: "Freight"
  30.       }
  31.     ]
  32.   },
  33.   { timestamps: { updatedAt: "updated_at", createdAt: "created_at" } }
  34. );
  35.  
  36. export default mongoose.model("Company", CompanySchema);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top