How to use the mongoose.Schemas function in mongoose

To help you get started, we’ve selected a few mongoose examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github EasyERP / EasyERP_open_source / updateCollections / Done / _updatewTracks.js View on Github external
jobs: {
        _id: {type: ObjectId, ref: 'jobs', default: null},
        name: {type: String, default: ''}
    }}, {collection: 'wTrack'});

function setPrice(num) {
    return num * 100;
}

mongoose.model('wTrackOld', wTrackSchema);

if (!mongoose.Schemas) {
    mongoose.Schemas = {};
}

mongoose.Schemas['wTrackOld'] = wTrackSchema;

var wTrackSchema = mongoose.Schemas['wTrack'];
var wTrackSchemaOld = mongoose.Schemas['wTrackOld'];

var dbObject = mongoose.createConnection('localhost', 'production');

dbObject.on('error', console.error.bind(console, 'connection error:'));
dbObject.once('open', function callback() {
    console.log("Connection to production is success");
});

var wTrackOld = dbObject.model("wTrackNew", wTrackSchemaOld);
var wTrack = dbObject.model("wTrack", wTrackSchema);

var query = wTrackOld.find().lean();
github EasyERP / EasyERP_open_source / updateCollections / toDo / updateProjectsSalesManagers.js View on Github external
bonus      : Array,
        projectTeam: [{type: ObjectId, ref: "jobs", default: null}]
    }
}, {collection: 'Project'});

projectSchema.set('toJSON', {virtuals: true});

mongoose.model('ProjectOld', projectSchema);

if (!mongoose.Schemas) {
    mongoose.Schemas = {};
}

mongoose.Schemas['ProjectOld'] = projectSchema;

var ProjectSchema = mongoose.Schemas['Project'];
var ProjectSchemaOld = mongoose.Schemas['ProjectOld'];

//var dbObject = mongoose.createConnection('localhost', 'production');

var connectOptions = {
    user  : 'easyerp',
    pass  : '1q2w3e!@#',
    w     : 1,
    j     : true
};

var dbObject = mongoose.createConnection('144.76.56.111', 'sergey', 28017, connectOptions);
dbObject.on('error', console.error.bind(console, 'connection error:'));
dbObject.once('open', function callback() {
    console.log("Connection to production is success");
});
github EasyERP / EasyERP_open_source / updateCollections / updateJobs.js View on Github external
/**
 * Created by liliya on 29.09.15.
 */
var mongoose = require('mongoose');
require('../models/index.js');
var ProjectSchema = mongoose.Schemas['Project'];
var wTrackSchema = mongoose.Schemas['wTrack'];
var MonthHoursSchema = mongoose.Schemas['MonthHours'];
var EmployeeSchema = mongoose.Schemas['Employee'];
var _ = require('../node_modules/underscore');
var async = require('async');
var JobsSchema = mongoose.Schemas['jobs'];

var dbObject = mongoose.createConnection('localhost', 'production');
dbObject.on('error', console.error.bind(console, 'connection error:'));
dbObject.once('open', function callback() {
    console.log("Connection to weTrack is success");

    var Project = dbObject.model('Project', ProjectSchema);
    var Employee = dbObject.model('Employees', EmployeeSchema);
    var Job = dbObject.model("jobs", JobsSchema);
    var paralellTasks;
    var count = 0;
github EasyERP / EasyERP_open_source / models / savedFilters.js View on Github external
var mongoose = require('mongoose');

    var savedFiltersSchema = mongoose.Schema({
        ID    : Number,
        name  : String,
        filter: JSON

    }, {collection: 'savedFilters'});

    mongoose.model('savedFilters', savedFiltersSchema);

    if (!mongoose.Schemas) {
        mongoose.Schemas = {};
    }

    mongoose.Schemas.savedFilters = savedFiltersSchema;
})();
github EasyERP / EasyERP_open_source / updateCollections / Done / generteOrders&Jobs.js View on Github external
/**
 * Created by liliya on 22.10.15.
 */
var mongoose = require('mongoose');
var ObjectId = mongoose.Schema.Types.ObjectId;
require('../models/index.js');
var async = require('async');
var QuotationSchema = mongoose.Schemas['Quotation'];
var InvoiceSchema = mongoose.Schemas['Invoice'];
var JobsSchema = mongoose.Schemas['jobs'];
var ProjectSchema = mongoose.Schemas['Project'];
var objectId = mongoose.Types.ObjectId;
var CONSTANTS = require('../constants/mainConstants');

var productService = CONSTANTS.PRODUCRSERVICE;

var wTrackSchema = mongoose.Schema({
    ID: Number,
    dateByWeek: Number,
    dateByMonth: Number,
    project: {
        _id: {
            type: ObjectId, ref: 'Project', default: null
        },
github EasyERP / EasyERP_open_source / updateCollections / Done / hidePurchasesJobsDashboard.js View on Github external
var mongoose = require('mongoose');
require('../../models/index.js');
var async = require('async');

var ModuleSchema = mongoose.Schemas.modules;

var connectOptions = {
    user: 'easyerp',
    pass: '1q2w3e!@#',
    w   : 1,
    j   : true
};

var dbObject = mongoose.createConnection('144.76.56.111', 'alex', 28017, connectOptions);

//var dbObject = mongoose.createConnection('localhost', 'production');

var Module = dbObject.model("modules", ModuleSchema);

var parallelTasks = [function (cb) {
    Module.update({_id: 54}, {visible : false}, cb);
github EasyERP / EasyERP_open_source / models / module.js View on Github external
ancestors: [Number],
        users    : {},
        parrent  : Number,
        sequence : Number,
        link     : Boolean,
        visible  : Boolean,
        single   : {type: Boolean, default: false}
    }, {collection: 'modules'});

    mongoose.model('modules', moduleSchema);

    if (!mongoose.Schemas) {
        mongoose.Schemas = {};
    }

    mongoose.Schemas.module = moduleSchema;
})();
github EasyERP / EasyERP_open_source / services / category.js View on Github external
'use strict';

var mongoose = require('mongoose');

var CategorySchema = mongoose.Schemas.ProductCategory;
var populateWrapper = require('../helpers/callbackWrapper').populate;
var validator = require('validator');
var _ = require('lodash');

module.exports = function (models) {
    return new function () {
        this.create = function (options, callback) {
            var dbName;
            var CategoryModel;
            var category;
            var err;

            if (typeof options === 'function') {
                callback = options;
                options = {};
            }
github EasyERP / EasyERP_open_source / models / project.js View on Github external
}],

        budget: {
            _id        : false,
            bonus      : Array,
            projectTeam: [{type: ObjectId, ref: 'jobs', default: null}]
        }
    }, {collection: 'Project'});

    mongoose.model('Project', projectSchema);

    if (!mongoose.Schemas) {
        mongoose.Schemas = {};
    }

    mongoose.Schemas.Project = projectSchema;
})();
github EasyERP / EasyERP_open_source / handlers / filter.js View on Github external
this.getSalesQuotationFilters = function (req, res, next) {
        var lastDB = req.session.lastDb;
        var QuotationSchema = mongoose.Schemas.Quotation;
        var Quotation = models.get(lastDB, 'Quotation', QuotationSchema);
        var pipeLine;
        var aggregation;
        var query = {
            forSales: true,
            isOrder : false
        };

        pipeLine = [{
            $match: query
        }, {
            $lookup: {
                from        : 'projectMembers',
                localField  : 'project',
                foreignField: 'projectId',
                as          : 'projectMembers'