https://github.com/fongandrew/meteor-collection2-common
Common Collection2 / SimpleSchema field definitions
https://github.com/fongandrew/meteor-collection2-common
Last synced: 3 months ago
JSON representation
Common Collection2 / SimpleSchema field definitions
- Host: GitHub
- URL: https://github.com/fongandrew/meteor-collection2-common
- Owner: fongandrew
- License: mit
- Created: 2015-07-08T23:22:07.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-07-08T23:34:03.000Z (almost 10 years ago)
- Last Synced: 2025-02-21T08:51:24.790Z (3 months ago)
- Language: JavaScript
- Size: 93.8 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# meteor-collection2-common
Some simple reusable schema definitions for aldeed:collection2 /
aldeed:simple-schema.Installation
------------
`meteor add fongandrew:collection2-common`Fields
------
In the list below, `attrs` param is an object containing additional keys to add
to our field definition.`CommonFields.autoId(attrs)` - Field which automatically populates
with a 17-character Meteor-style random _id.`CommonFields.idField(attrs, length)` - Field for validating a Meteor-style
_id. Length defaults to 17 characters.`CommonFields.createdOn(attrs)` - Timestamp for document creation
`CommonFields.updatedOn(attrs)` - Timestamp for document update
`CommonFields.stateVerifier(attrs)` - Random string for each time field is
updated, useful for ensuring that we don't clobber something we don't intend
to because of Mongo's lack of built-in transactions`CommonFields.isActive(attrs)` - Boolean that gets set to true every time
this document is updated.`CommonFields.autoBool(defaultValue, attrs)` - Sets a default bool at creation
and no other time`CommonFields.rank(attrs)` - Generates an autoValue decimal number based on the
current time. Useful if you want a modifiable "rank" for sorting purposes that's
loosely tied to creation time.`CommonFields.autoInc(attrs)` - An auto-incrementing number on each update
(starts @ 1, not 0) -- you can disable by passing an explicitly falsey value.
Field will not increment but stay at whatever it previously was.