Interface DocumentKeyRule

interface DocumentKeyRule {
    choices?: any[];
    collection?: string;
    default?: any;
    invalidateOnMinMaxError?: boolean;
    match?: string | RegExp;
    max?: number;
    maxLength?: number;
    min?: number;
    minLength?: number;
    padArrayValue?: any;
    padStringValue?: string;
    required?: boolean;
    type: any;
    unique?: boolean;
    validate?: Function;
}

Properties

choices?: any[]

An array of data that should match the specified type, to restrict the possible values of this property.

BigfootDS

collection?: string

Used for properties that are references to other documents. The value of this should be the name of the collection that the referenced document lives in. eg. collection: "Users", would be useful for refering to documents that live in a "Users" collection of a database. No, you cannot refer to collections that exist in separate database clients.

BigfootDS

default?: any

The default data of this property, to be used if no data is provided or if a soft-invalidation occurs.

BigfootDS

invalidateOnMinMaxError?: boolean

Determines whether not an invalid value for min, max, minLength, and maxLength properties will throw an error or just roll-over and allow the value to exist. Depending on the property, it may get replaced with a default or min or max value if this is set to false.

BigfootDS

match?: string | RegExp

The regex expression that will be run against this property's data value. If the regex doesn't match, validation fails.

BigfootDS

max?: number

The highest value that this property can have for its data value. For properties that are numbers.

BigfootDS

maxLength?: number

The highest length that this property can have for its data value. For properties that are strings or arrays.

BigfootDS

min?: number

The lowest value that this property can have for its data value. For properties that are numbers.

BigfootDS

minLength?: number

The shortest length that this property can have for its data value. For properties that are strings or arrays.

BigfootDS

padArrayValue?: any

If an array data value's length is too short, this is the value that will be used to pad the array until it meets the minLength property.

BigfootDS

padStringValue?: string

If a string data value is too short, this is the value that will be used to pad the data until it meets the minLength property.

BigfootDS

required?: boolean

Whether or not a property defined in the document's rules object must have a value in its data.

BigfootDS

type: any

A JavaScript class or type. This should be on every document key rule object, it is required. Various other constraints depend on the type!

BigfootDS

unique?: boolean

Whether or not the data value for this property should be unique within the database. This sets up a NeDB index, so it's not immediately checked at a SuperCamo level - but NeDB immediately enforces it.

BigfootDS

validate?: Function

A custom validate function that runs alongside any other constraints. The function must receive one parameter, which the document will pass in automatically - the parameter is the document's data for this property.

BigfootDS