How to use mongoose-types - 10 common examples

To help you get started, we’ve selected a few mongoose-types 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 kof / kiipost / api / db / index.js View on Github external
return new Promise(function(fulfill, reject{
        // Register all types from mongoose.
        types.loadTypes(m)

        schemas.forEach(function(name{
            m.model(name, require('./schemas/' + name))
        })

        m.connect(conf.db.url, _.clone(conf.db.options), function(err{
            err ? reject(err) : fulfill(m.connection)
        })
        m.connection.on('error', log)
    })
}
github openhab / openhab-cloud / app.js View on Github external
// MongoDB connection settings
var mongoose = require('mongoose');
var cacheOpts = {
    max: 5000,
    maxAge: 1000 * 60 * 10
};

require('mongoose-cache').install(mongoose, cacheOpts);

// Try to setup a mongodb connection, otherwise stopping
var mongoConnect = new MongoConnect(system);
mongoConnect.connect(mongoose);

var mongooseTypes = require('mongoose-types');
mongooseTypes.loadTypes(mongoose);

var app = express();

// A list of requests which are awaiting for responses from openHABs
var requestTracker = new requesttracker();

// A list of openHABs which lost their socket.io connection and are due for offline notification
// key is openHAB UUID, value is Date when openHAB was disconnected
var offlineOpenhabs = {};

/**
 * Callback for the 'check offline openHABs' scheduled task to notify the owner of an openHAB, that the instance
 * is offline.
 *
 * @param error The error, if an error occured
 * @param {Openhab} openhab The openHAB instance
github Lambda-School-Labs / CS10-restaurant-pos / api / models / Employee.js View on Github external
const mongoose = require('mongoose');
const bcrypt = require('bcryptjs');
const mongooseTypes = require('mongoose-types');
// Loads into Mongoose Schema Types
mongooseTypes.loadTypes(mongoose, 'email');

const { Schema } = mongoose;
const { ObjectId } = Schema.Types;
const { Email } = mongoose.SchemaTypes;

const Employee = new Schema({
  name: {
    type: String,
    required: true,
  },
  password: {
    type: String,
    required: true,
  },
  pin: {
    type: String,
github SportZing / mongoose-models / lib / index.js View on Github external
conf.types.forEach(function(type) {
			// These comes with mongoose-types
			if (type === 'url' || type === 'email') {
				mongooseTypes.loadTypes(mongoose, type);
			}
			// If it starts with a dot or slash, assume its a file path
			else if (type[0] === '.' || type[1] === '/') {
				require('type').load(mongoose, exports);
			}
			// Anything else is assumed to be from us
			else {
				require('./types/' + type).load(mongoose, exports);
			}
		});
	}
github storj / service-storage-models / test / cron.unit.js View on Github external
'use strict';

const chai = require('chai');
const expect = chai.expect;
const sinon = require('sinon');
const chaiDate = require('chai-datetime');
const mongoose = require('mongoose');

chai.use(chaiDate);
require('mongoose-types').loadTypes(mongoose);

const CronSchema = require('../lib/models/cron');

var Cron;
var connection;

before(function(done) {
  connection = mongoose.createConnection(
    'mongodb://127.0.0.1:27017/__storj-bridge-test',
    function() {
      Cron = CronSchema(connection);
      Cron.remove({}, function() {
        done();
      });
    }
  );
github storj / service-storage-models / test / storage-event.unit.js View on Github external
'use strict';

const expect = require('chai').expect;
const mongoose = require('mongoose');

require('mongoose-types').loadTypes(mongoose);

const StorageEventSchema = require('../lib/models/storage-event');

var StorageEvent;
var connection;

before(function(done) {
  connection = mongoose.createConnection(
    'mongodb://127.0.0.1:27017/__storj-bridge-test',
    function() {
      StorageEvent = StorageEventSchema(connection);
      StorageEvent.remove({}, function() {
        done();
      });
    }
  );
github openhab / openhab-cloud / makeinvites.js View on Github external
var config = require('./config.json'),
    mongoose = require('mongoose'),
    uuid = require('uuid'),
    mongooseTypes = require('mongoose-types'),
    Invitation = require('./models/invitation'),
    system = require('./system'),
    MongoConnect = require('./system/mongoconnect'),
    mongoConnect;

system.setConfiguration(config);
mongoConnect = new MongoConnect(system);
mongoConnect.connect(mongoose);
mongooseTypes.loadTypes(mongoose);

console.log('Making 10 invitations!');
for (i=0; i<10; i++) {
    var invitationCode,
        invite;

    invitationCode = uuid.v1();
    invite = new Invitation({code: invitationCode, email: 'openhab@openhab.org'});
    console.log('openHAB-cloud: New invitation code ' + invitationCode);
    invite.save(function (err, invitation) {
        console.log('callback');
        if (err) {
            console.log('Error');
        } else {
            console.log('Saved: ' + invitation);
        }
github panbhag / easybackend / config / initializers / 02_mongoose.js View on Github external
var mongoose = require('mongoose');
var dbName = "backend"
var dbServerURL = 'mongodb://localhost/'; 
var dbConnectionString = dbServerURL + dbName;
var  db = mongoose.connect(dbConnectionString); 
var mongooseTypes = require("mongoose-types");
mongooseTypes.loadTypes(mongoose);
github bnoguchi / mongoose-auth / lib / modules / facebook / plugin.js View on Github external
var mongoose = require('mongoose')
  , mongooseTypes = require('mongoose-types')
  , _schema = require('./schema')
  , everyauth = require('everyauth');
mongooseTypes.loadTypes(mongoose);
var Email = mongoose.SchemaTypes.Email;

module.exports = function facebook (schema, opts) {
  schema.add(_schema);

  schema.static('createWithFB', function (fbUserMeta, accessToken, expires, callback) {
    var params =  {
      fb: {
          id: fbUserMeta.id
        , accessToken: accessToken
        , expires: expires
        , name: {
              full: fbUserMeta.name
            , first: fbUserMeta.first_name
            , last: fbUserMeta.last_name
          }
github bnoguchi / mongoose-auth / lib / modules / google / plugin.js View on Github external
var mongoose = require('mongoose')
  , mongooseTypes = require('mongoose-types')
  , _schema = require('./schema')
  , everyauth = require('everyauth');
mongooseTypes.loadTypes(mongoose);

module.exports = function google (schema, opts) {
  schema.add(_schema);

  schema.static('createWithGoogleOAuth', function (googleUser, accessToken, accessTokenExtra, callback) {
    var expiresDate = new Date;
    expiresDate.setSeconds(expiresDate.getSeconds() + accessTokenExtra.expires_in);
    
    var params = {
      google: {
          email: googleUser.id
        , expires: expiresDate
        , accessToken: accessToken
        , refreshToken: accessTokenExtra.refresh_token
      }
    };

mongoose-types

More types for mongoose

Unknown
Latest version published 14 years ago

Package Health Score

45 / 100
Full package analysis

Popular mongoose-types functions