How to use feathers-mongodb - 10 common examples

To help you get started, we’ve selected a few feathers-mongodb 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 feathers-plus / generator-feathers-plus / test-expands / ts-cumulative-1-mongo.test-expected / src1 / services / nedb-1 / nedb-1.service.ts View on Github external
let moduleExports = function (app: App) {
  let paginate = app.get('paginate');
  let mongoClient = app.get('mongoClient') as Promise;
  let options = { paginate };
  // !code: func_init // !end

  // Initialize our service with any options it requires
  // ! code: extend
  app.use('/nedb-1', createService(options));
  // !end

  // Get our initialized service so that we can register hooks
  const service = app.service('nedb-1');

  // eslint-disable-next-line no-unused-vars
  let promise = mongoClient.then(db => {
    return db.createCollection('nedb-1', {
      // ! code: create_collection
      // validator: { $jsonSchema: $jsonSchema },
      // validationLevel: 'strict', // The MongoDB default
      // validationAction: 'error', // The MongoDB default
      // !end
    });
  })
    .then(serviceModel => {
github feathers-plus / generator-feathers-plus / test-expands / ts-cumulative-1-mongo.test-expected / src1 / services / users-1 / users-1.service.ts View on Github external
let moduleExports = function (app: App) {
  let paginate = app.get('paginate');
  let mongoClient = app.get('mongoClient') as Promise;
  let options = { paginate };
  // !code: func_init // !end

  // Initialize our service with any options it requires
  // ! code: extend
  app.use('/users-1', createService(options));
  // !end

  // Get our initialized service so that we can register hooks
  const service = app.service('users-1');

  // eslint-disable-next-line no-unused-vars
  let promise = mongoClient.then(db => {
    return db.createCollection('users-1', {
      // ! code: create_collection
      // validator: { $jsonSchema: $jsonSchema },
      // validationLevel: 'strict', // The MongoDB default
      // validationAction: 'error', // The MongoDB default
      // !end
    });
  })
    .then(serviceModel => {
github feathers-plus / generator-feathers-plus / test-expands / ts-cumulative-1-mongo.test-expected / src1 / services / nedb-2 / nedb-2.service.ts View on Github external
let moduleExports = function (app: App) {
  let paginate = app.get('paginate');
  let mongoClient = app.get('mongoClient') as Promise;
  let options = { paginate };
  // !code: func_init // !end

  // Initialize our service with any options it requires
  // ! code: extend
  app.use('/nedb-2', createService(options));
  // !end

  // Get our initialized service so that we can register hooks
  const service = app.service('nedb-2');

  // eslint-disable-next-line no-unused-vars
  let promise = mongoClient.then(db => {
    return db.createCollection('nedb-2', {
      // ! code: create_collection
      // validator: { $jsonSchema: $jsonSchema },
      // validationLevel: 'strict', // The MongoDB default
      // validationAction: 'error', // The MongoDB default
      // !end
    });
  })
    .then(serviceModel => {
github feathers-plus / generator-feathers-plus / test / ts-cumulative-1-mongo.test-expected / src1 / services / users-1 / users-1.service.ts View on Github external
let moduleExports = function (app: App) {
  let paginate = app.get('paginate');
  let mongoClient = app.get('mongoClient') as Promise;
  let options = { paginate };
  // !code: func_init // !end

  // Initialize our service with any options it requires
  app.use('/users-1', createService(options));

  // Get our initialized service so that we can register hooks
  const service = app.service('users-1');

  mongoClient.then(db => {
    return db.createCollection('users-1', {
      // ! code: create_collection
      // validator: { $jsonSchema: $jsonSchema },
      // validationLevel: 'strict', // The MongoDB default
      // validationAction: 'error', // The MongoDB default
      // !end
    });
  })
    .then(serviceModel => {
      (service as any).Model = serviceModel;
    });
github feathers-plus / generator-feathers-plus / test / ts-cumulative-1-mongo.test-expected / src1 / services / nedb-1 / nedb-1.service.ts View on Github external
let moduleExports = function (app: App) {
  let paginate = app.get('paginate');
  let mongoClient = app.get('mongoClient') as Promise;
  let options = { paginate };
  // !code: func_init // !end

  // Initialize our service with any options it requires
  app.use('/nedb-1', createService(options));

  // Get our initialized service so that we can register hooks
  const service = app.service('nedb-1');

  mongoClient.then(db => {
    return db.createCollection('nedb-1', {
      // ! code: create_collection
      // validator: { $jsonSchema: $jsonSchema },
      // validationLevel: 'strict', // The MongoDB default
      // validationAction: 'error', // The MongoDB default
      // !end
    });
  })
    .then(serviceModel => {
      (service as any).Model = serviceModel;
    });
github feathers-plus / generator-feathers-plus / test / ts-cumulative-1-mongo.test-expected / src1 / services / nedb-2 / nedb-2.service.ts View on Github external
let moduleExports = function (app: App) {
  let paginate = app.get('paginate');
  let mongoClient = app.get('mongoClient') as Promise;
  let options = { paginate };
  // !code: func_init // !end

  // Initialize our service with any options it requires
  app.use('/nedb-2', createService(options));

  // Get our initialized service so that we can register hooks
  const service = app.service('nedb-2');

  mongoClient.then(db => {
    return db.createCollection('nedb-2', {
      // ! code: create_collection
      // validator: { $jsonSchema: $jsonSchema },
      // validationLevel: 'strict', // The MongoDB default
      // validationAction: 'error', // The MongoDB default
      // !end
    });
  })
    .then(serviceModel => {
      (service as any).Model = serviceModel;
    });
github donejs / place-my-order / lib / api.js View on Github external
});

      return Object.keys(result).map(key => result[key]);
    }))
    .get('/cities', fromRestaurants(restaurants => {
      let result = {};
      restaurants.data.forEach(restaurant => {
        let name = restaurant.address.city;
        if(!result[name]) {
          result[name] = { name, state: restaurant.address.state };
        }
      });

      return Object.keys(result).map(key => result[key]);
    }))
    .use('/restaurants', mongodb({
      collection: 'restaurants',
      connectionString: config.mongodb
    }))
    .use('/orders', mongodb({
      collection: 'orders',
      connectionString: config.mongodb
    }));

  // Override listen because we need the server to set up the API
  let oldListen = this.listen;
  this.listen = function() {
    let server = oldListen.apply(this, arguments);
    api.setup(server);
    return server;
  };
github feathersjs / generator-feathers / generators / service / templates / ts / types / mongodb.ts View on Github external
export default function (app: Application) {
  const paginate = app.get('paginate');
  const mongoClient = app.get('mongoClient');
  const options = { paginate };

  // Initialize our service with any options it requires
  app.use('/<%= path %>', createService(options));

  // Get our initialized service so that we can register hooks and filters
  const service = app.service('<%= path %>');

  mongoClient.then(db => {
    service.Model = db.collection('<%= kebabName %>');
  });

  service.hooks(hooks);
}
github mysamai / mysam / lib / services.js View on Github external
import mongodb from 'feathers-mongodb';
import Q from 'q';

const connectionString = "mongodb://localhost:27017/sam";

export const actions = mongodb({
  connectionString,
  collection: 'actions'
});

export const learnings = mongodb({
  connectionString,
  collection: 'learning'
}).extend({
  create(data, params, callback) {
    let actions = this.app.service('actions');
    let _super = this._super.bind(this);

    if(typeof data.action === 'object') {
      return Q.ninvoke(actions, 'create', data.action)
        .then(action => Q.nfcall(_super, { input: data.input, action: action._id }))
        .nodeify(callback);
    }

    return _super(... arguments);
  },
github mysamai / mysam / lib / services.js View on Github external
import mongodb from 'feathers-mongodb';
import Q from 'q';

const connectionString = "mongodb://localhost:27017/sam";

export const actions = mongodb({
  connectionString,
  collection: 'actions'
});

export const learnings = mongodb({
  connectionString,
  collection: 'learning'
}).extend({
  create(data, params, callback) {
    let actions = this.app.service('actions');
    let _super = this._super.bind(this);

    if(typeof data.action === 'object') {
      return Q.ninvoke(actions, 'create', data.action)
        .then(action => Q.nfcall(_super, { input: data.input, action: action._id }))
        .nodeify(callback);

feathers-mongodb

Feathers MongoDB service

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular feathers-mongodb functions