Advertisement
Guest User

Untitled

a guest
Aug 14th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  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);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement