Coder Social home page Coder Social logo

meteor-protomongo's Introduction

@codesignal/meteor-protomongo
npm version

Monkey-patches to meteor/mongo.

Helpful for working with indexes and transitioning away from Fibers.

Update, November 2022:

Meteor 2.8 updated the core meteor/mongo package to add *Async versions of Mongo methods by default. See: meteor/meteor#11605

Since the new core methods have identical signatures to the ones previously provided by this package, the 3.x release of this package has been updated to remove the overlapping methods.

Now, the package only includes helpers related to working with indexes or aggregation.

Description

This package extends the Collection prototype from meteor/mongo with a few handy helpers related to indexes and aggregation. It's intended for use only with projects built with Meteor.

API

Collection Prototype

Collection.updateManyAsync(selector, modifier, ?options);

Same as Collection.updateAsync; passes { multi: true } in addition to the passed options.

Collection.getIndexes();

Returns a Promise that is resolved with an array of indexes for this collection. For example, you might see this for a users collection with only an index on ID:

[{ v: 2, key: { _id: 1 }, name: '_id_', ns: 'meteor.users' }]
Collection.ensureIndex(selector, options);

Ensures an index exists. Similar to the built-in createIndex, but handles the case where the index already exists with different options by removing and re-adding the index with the new options. To ensure your database has the same indexes across different environments, you might want to add ensureIndex calls to Meteor.startup.

Collection.ensureNoIndex(selector);

The reverse of ensureIndex. You might want to call this in Meteor.startup to make sure an index has been removed in all of your deployed environments.

Collection.aggregate(pipeline, ?options);

Exposes the aggregate method. This removes the need to use rawCollection() every time you want to aggregate.

Install

npm install @codesignal/meteor-protomongo

After the package is installed, add the following few lines in a file that's going to be loaded on startup:

import { Mongo } from 'meteor/mongo';
import ProtoMongo from '@codesignal/meteor-protomongo';

ProtoMongo.extendCollection(Mongo);

Building Locally

After checking out this repo, run...

npm install
npm run build

To do local checks:

npm run eslint

Contributing

If you'd like to make a contribution, please open a pull request in package repository.

If you want (and have the right permissions) to publish a new version, please follow the instructions below:

  • Make sure you have NPM account and are a member of codesignal organization;
  • Follow instructions from npm docs to set up NPM user in your local environment;
  • Update package version and push changes to git by running these commands: npm version <new_version>, git push origin master, git push --tags;
  • Publish the updated package with npm publish --access public.

License

MIT

meteor-protomongo's People

Contributors

albinutte avatar arthurhoaro avatar dependabot-preview[bot] avatar dependabot[bot] avatar menewman avatar miamagana avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

user01010011

meteor-protomongo's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.