aldeed:schema-deny

v1.0.1Published 8 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

Build Status

aldeed:schema-deny

A Meteor package that allows you to deny inserting or updating certain properties in your database by setting options in your schema. This package is currently included automatically with the aldeed:collection2 package.

Installation

In your Meteor app directory, enter:

$ meteor add aldeed:schema-deny

Usage

If you set denyUpdate: true, any collection update that modifies the field will fail. For instance:

1var PostSchema = new SimpleSchema({
2  title: {
3    type: String
4  },
5  content: {
6    type: String
7  },
8  createdAt: {
9    type: Date,
10    denyUpdate: true
11  }
12});
13
14Posts = new Mongo.Collection('posts');
15Posts.attachSchema(PostSchema);
16
17var postId = Posts.insert({title: 'Hello', content: 'World', createdAt: new Date()});

The denyInsert option works the same way, but for inserts. If you set denyInsert to true, you will need to set optional: true as well.

Contributing

Anyone is welcome to contribute. Fork, make and test your changes (meteor test-packages ./), and then submit a pull request.