feat: Adding groups feature without privacity enabled
This commit is contained in:
12
v1/src/lib/Models/company_groups.models.js
Normal file
12
v1/src/lib/Models/company_groups.models.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const mongoose = require('mongoose');
|
||||
const { Schema } = mongoose;
|
||||
|
||||
const schema = new Schema({
|
||||
owner: { type: Schema.Types.ObjectId, ref: 'companies', required: true }, /// Company owner of this list
|
||||
list_name: { type: String }, /// Name of the list
|
||||
allowedCompanies: [{ type: Schema.Types.ObjectId, ref: 'companies' }], /// Behaves as a tuple, not repeated elements
|
||||
createdAt: { type : Date, required : true, default : () => { return Date.now(); } },
|
||||
updatedAt: { type : Date, required : true, default : () => { return Date.now(); } }
|
||||
});
|
||||
|
||||
module.exports = mongoose.model( "companygroups", schema );
|
||||
@@ -4,9 +4,11 @@ const branches = require('./branches.model.js');
|
||||
const budgets = require('./budgets.model.js');
|
||||
const cities = require('./cities.model.js');
|
||||
const companies = require('./companies.model.js');
|
||||
const companygroups = require('./company_groups.models.js')
|
||||
const countries = require('./countries.model.js');
|
||||
const load_attachments = require('./load-attachments.model.js');
|
||||
const loads = require('./loads.model.js');
|
||||
const loadtemplates = require('./load_templates.model.js');
|
||||
const mailer = require('./mailer.model.js');
|
||||
const memberships = require('./memberships.model.js');
|
||||
const meta_data = require('./meta-data.model.js');
|
||||
@@ -34,12 +36,16 @@ function getModel( name ){
|
||||
return cities;
|
||||
case 'companies':
|
||||
return companies;
|
||||
case 'company_groups':
|
||||
return companygroups;
|
||||
case 'countries':
|
||||
return countries;
|
||||
case 'load_attachments':
|
||||
return load_attachments;
|
||||
case 'loads':
|
||||
return loads;
|
||||
case 'load_templates':
|
||||
return loadtemplates;
|
||||
case 'mailer':
|
||||
return mailer;
|
||||
case 'memberships':
|
||||
|
||||
67
v1/src/lib/Models/load_templates.model.js
Normal file
67
v1/src/lib/Models/load_templates.model.js
Normal file
@@ -0,0 +1,67 @@
|
||||
const mongoose = require('mongoose');
|
||||
const { Schema } = mongoose;
|
||||
|
||||
const address = new Schema({
|
||||
company_name: { type: String },
|
||||
|
||||
street_address1: { type: String },
|
||||
street_address2: { type: String },
|
||||
city: { type: String },
|
||||
state: { type: String },
|
||||
country: { type: String },
|
||||
zipcode: { type: String },
|
||||
|
||||
landmark: { type: String },
|
||||
|
||||
lat: { type: String },
|
||||
lng: { type: String },
|
||||
});
|
||||
|
||||
|
||||
const pointSchema = new Schema({
|
||||
type: {
|
||||
type: String,
|
||||
enum: ['Point'],
|
||||
required: true
|
||||
},
|
||||
coordinates: {
|
||||
type: [Number],
|
||||
required: true
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
const schema = new Schema({
|
||||
company: { type: Schema.Types.ObjectId, ref: 'companies', required: true },
|
||||
|
||||
alert_list: [{ type: String, lowercase: true }],
|
||||
|
||||
origin_warehouse : { type: Schema.Types.ObjectId, ref: 'branches' },
|
||||
destination_warehouse : { type: Schema.Types.ObjectId, ref: 'branches' },
|
||||
|
||||
origin: address,
|
||||
origin_geo: {
|
||||
type: pointSchema,
|
||||
},
|
||||
destination: address,
|
||||
destination_geo: {
|
||||
type: pointSchema,
|
||||
},
|
||||
|
||||
categories: [{ type: Schema.Types.ObjectId, ref: 'productcategories' }],
|
||||
product: { type: Schema.Types.ObjectId, ref: 'products' },
|
||||
|
||||
truck_type: { type: String },
|
||||
tyre_type: { type: String },
|
||||
weight: { type: Number },
|
||||
estimated_cost: { type: Number },
|
||||
|
||||
distance: { type: Number },
|
||||
actual_cost: { type: Number },
|
||||
notes: { type: String },
|
||||
|
||||
created_by: { type: Schema.Types.ObjectId, ref: 'users' }, // shipper
|
||||
createdAt: { type : Date, required : true, default : () => { return Date.now(); } }
|
||||
});
|
||||
|
||||
module.exports = mongoose.model( "loadtemplates", schema );
|
||||
Reference in New Issue
Block a user