Skip to content

Deny inserting or updating certain properties through schema options

License

Notifications You must be signed in to change notification settings

Meteor-Community-Packages/meteor-schema-deny

Repository files navigation

CircleCI

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.

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:

const postSchema = new SimpleSchema({
  title: {
    type: String
  },
  content: {
    type: String
  },
  createdAt: {
    type: Date,
    denyUpdate: true
  }
});

const Posts = new Mongo.Collection('posts');
Posts.attachSchema(postSchema);

const 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.

Running Tests

cd tests
npm i && npm test

Running Tests in Watch Mode

cd tests
npm i && npm run test:watch

About

Deny inserting or updating certain properties through schema options

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  
  •  
  •  

Contributors 3

  •  
  •  
  •