All Projects → zimme → Meteor Collection Softremovable

zimme / Meteor Collection Softremovable

Licence: mit
Add soft remove to collections

Programming Languages

coffeescript
4710 projects

Labels

Projects that are alternatives of or similar to Meteor Collection Softremovable

Db
GroundDB is a thin layer providing Meteor offline database and methods
Stars: ✭ 569 (+1862.07%)
Mutual labels:  meteor
Meteor Roles
Authorization package for Meteor, compatible with built-in accounts packages
Stars: ✭ 916 (+3058.62%)
Mutual labels:  meteor
Sapporo
Web App for hosting coding competition
Stars: ✭ 10 (-65.52%)
Mutual labels:  meteor
React Native Meteor Boilerplate
Stars: ✭ 637 (+2096.55%)
Mutual labels:  meteor
Nlg Eval
Evaluation code for various unsupervised automated metrics for Natural Language Generation.
Stars: ✭ 822 (+2734.48%)
Mutual labels:  meteor
Mongol Meteor Explore Minimongo Devtools
In-App MongoDB Editor for Meteor (Meteor DevTools)
Stars: ✭ 846 (+2817.24%)
Mutual labels:  meteor
Pup
The Ultimate Boilerplate for Products.
Stars: ✭ 563 (+1841.38%)
Mutual labels:  meteor
Rocket.chat
The communications platform that puts data protection first.
Stars: ✭ 31,251 (+107662.07%)
Mutual labels:  meteor
Vue Meteor
🌠 Vue first-class integration in Meteor
Stars: ✭ 893 (+2979.31%)
Mutual labels:  meteor
Retrotanks
RetroTanks: Atari Combat Reimagined, built in Meteor.js. Great isomorphic JavaScript example.
Stars: ✭ 9 (-68.97%)
Mutual labels:  meteor
Meteor Collection Hooks
Meteor Collection Hooks
Stars: ✭ 641 (+2110.34%)
Mutual labels:  meteor
Demeteorizer
Converts a Meteor app into a standard Node.js application.
Stars: ✭ 717 (+2372.41%)
Mutual labels:  meteor
Ostrio Analytics
📊 Visitor's analytics tracking code for ostr.io service
Stars: ✭ 9 (-68.97%)
Mutual labels:  meteor
Meteor Astronomy
Model layer for Meteor
Stars: ✭ 608 (+1996.55%)
Mutual labels:  meteor
Kickstart Meteor Polymer
⚡️ Kickstart a Meteor - Polymer project with MWC packages. (Flow Router is used to route)
Stars: ✭ 15 (-48.28%)
Mutual labels:  meteor
Dtube
📺 d.tube app. A full-featured video sharing website, decentralized.
Stars: ✭ 569 (+1862.07%)
Mutual labels:  meteor
Meteor Boilerplate
A lightweight boilerplate for meteor projects
Stars: ✭ 841 (+2800%)
Mutual labels:  meteor
Create React Meteor App
Meteor + React for fast prototyping 🔥🔥
Stars: ✭ 28 (-3.45%)
Mutual labels:  meteor
Rate Limit
Meteor package to rate-limit a function by queuing up calls (instead of dropping them like throttle or debounce)
Stars: ✭ 15 (-48.28%)
Mutual labels:  meteor
Meteor Google Charts
Simple package for Google Charts on Meteor
Stars: ✭ 9 (-68.97%)
Mutual labels:  meteor

[Gitter] (https://gitter.im/zimme/meteor-collection-softremovable) [Code Climate] (https://codeclimate.com/github/zimme/meteor-collection-softremovable)

Soft remove for collections

Add soft remove to collections.

Install

meteor add zimme:collection-softremovable

Usage

Basic usage examples.

Attach

Posts = new Mongo.Collection('posts');

//Attach behaviour with the default options
Posts.attachBehaviour('softRemovable');

//Attach behaviour with custom options
Posts.attachBehaviour('softRemovable', {
  removed: 'deleted',
  removedBy: false,
  restoredAt: 'undeletedAt',
  restoredBy: false
});

Remove/Restore

// Soft remove document by _id
Posts.softRemove({_id: 'BFpDzGuWG8extPwrE'});

// Restore document by _id
Posts.restore('BFpDzGuWG8extPwrE');

// Actually remove document from collection
Posts.remove({_id: 'BFpDzGuWG8extPwrE'});

Find

// Find all posts except soft removed posts
Posts.find({});

// Find only posts that have been soft removed
Posts.find({removed: true});

// Find all posts including removed
Posts.find({}, {removed: true});

Publish

For you to be able to find soft removed documents on the client you will need to explicitly publish those. The example code below belongs in server-side code.

Meteor.publish('posts', function() {
  return Posts.find({});
});

Meteor.publish('removedPosts', function() {
  return Posts.find({removed: true});
});

Meteor.publish('allPosts', function() {
  return Posts.find({}, {removed: true});
});

Options

The following options can be used:

  • removed: Optional. Set to 'string' to change the fields name. This field can't be omitted.

  • removedAt: Optional. Set to 'string' to change the fields name. Set to false to omit field.

  • removedBy: Optional. Set to 'string' to change the fields name. Set to false to omit field.

  • restoredAt: Optional. Set to 'string' to change the fields name. Set to false to omit field.

  • restoredBy: Optional. Set to 'string' to change the fields name. Set to false to omit field.

  • systemId: Optional. Set to 'string' to change the id representing the system.

Global configuration

// Configure behaviour globally
// All collection using this behaviour will use these settings as defaults
// The settings below are the package default settings
CollectionBehaviours.configure('softRemovable',{
  removed: 'removed',
  removedAt: 'removedAt',
  removedBy: 'removedBy',
  restoredAt: 'restoredAt',
  restoredBy: 'restoredAt',
  systemId: '0'
});

Notes

  • This package attaches a schema to the collection if aldeed:simple-schema, aldeed:collection2 and/or aldeed:autoform are used in the application.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].