Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/meteor-community-packages/meteor-schema-deny
Deny inserting or updating certain properties through schema options
https://github.com/meteor-community-packages/meteor-schema-deny
meteorjs mongodb schema
Last synced: about 1 month ago
JSON representation
Deny inserting or updating certain properties through schema options
- Host: GitHub
- URL: https://github.com/meteor-community-packages/meteor-schema-deny
- Owner: Meteor-Community-Packages
- License: mit
- Created: 2015-12-30T03:37:00.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-05-04T19:46:11.000Z (7 months ago)
- Last Synced: 2024-10-14T03:41:57.042Z (about 1 month ago)
- Topics: meteorjs, mongodb, schema
- Language: JavaScript
- Homepage:
- Size: 137 KB
- Stars: 12
- Watchers: 1
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
[![CircleCI](https://circleci.com/gh/aldeed/meteor-schema-deny/tree/master.svg?style=svg)](https://circleci.com/gh/aldeed/meteor-schema-deny/tree/master)
# 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:
```bash
meteor add aldeed:schema-deny
```## Usage
If you set `denyUpdate: true`, any collection update that modifies the field will fail. For instance:
```js
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
```bash
cd tests
npm i && npm test
```### Running Tests in Watch Mode
```bash
cd tests
npm i && npm run test:watch
```