Interception module for creating and updating fields automatically. That is, fields that don't have to be explicitly set on a document.
The folowing fields are supported:
Type | Default field name | Description |
---|---|---|
Created At | _createdAt | Date and time when the item was first added to the collection. |
Created By | _createdBy | The identifier of the user that first added the item to the collection. |
Last Modified | _lastModified | Date and time of the last update of the item. |
Modified By | _modifiedBy | The identifier of the user that made the last update of the item. |
Version | _version | The number of times the item was successfully updated. |
For more details on using interceptors please see the Interceptors tutorial.
- Source:
Example
var entree = require("entree"), autofields = entree.resolveInterceptor("autofields"); entree.posts.use(autofields.interception({ createdAt: true, version: "_myUpdateCountField" }));
Methods
-
<static> interception(opts) → {function}
-
Configures and returns an interceptor function.
Options
createdAt
{(boolean|string)=} - if true, defaults to "_createdAt".createdBy
{(boolean|string)=} - if true, defaults to "_createdBy".lastModified
{(boolean|string)=} - if true, defaults to "_lastModified".modifiedBy
{(boolean|string)=} - if true, defaults to "_modifiedBy".version
{(boolean|string)=} - if true, defaults to "_version".
If any of the options is a string, then the value is used for field name for that option. If options are omitted, all supported fields will be configured with their default names.
Parameters:
Name Type Argument Description opts
object <optional>
Autofields options, defines which auto-fileds should be handled and their names.
- Source:
Returns:
- Type
- function