Class: ArrayType
Array type supports arrays of SchemaTypes and arrays of subdocuments.
Options
- required flag to define if the field is mandatory
- validator that will be applied to the field, allowed function, object or string with the name of the custom validator
- default that will define the initial value of the field, allowed and value or function to generate it
- immutable that will define this field as immutable. Ottoman prevents you from changing immutable fields if the schema as configure like strict
Example
const postSchemaDef = new Schema({
postTags: [String],
comments: [{ type: commentSchema, ref: 'Comment' }],
});
Hierarchy
↳
ArrayType
Constructors
constructor
• new ArrayType(name
, itemType
, options?
)
Parameters
Name | Type |
---|---|
name | string |
itemType | IOttomanType |
options? | CoreTypeOptions |
Overrides
Defined in
Properties
itemType
• itemType: IOttomanType
Defined in
name
• name: string
Inherited from
Defined in
schema/interfaces/schema.types.ts:51
options
• Optional
options: CoreTypeOptions
Inherited from
Defined in
typeName
• typeName: string
Inherited from
Defined in
schema/interfaces/schema.types.ts:51
sName
▪ Static
sName: string
= Array.name
Overrides
Defined in
Accessors
default
• get
default(): unknown
Returns
unknown
Inherited from
CoreType.default
Defined in
required
• get
required(): boolean
| RequiredOption
| RequiredFunction
Returns
boolean
| RequiredOption
| RequiredFunction
Inherited from
CoreType.required
Defined in
validator
• get
validator(): undefined
| string
| ValidatorFunction
| ValidatorOption
Returns
undefined
| string
| ValidatorFunction
| ValidatorOption
Inherited from
CoreType.validator
Defined in
Methods
buildDefault
▸ buildDefault(): unknown
Returns
unknown
Inherited from
Defined in
cast
▸ cast(value
, strategy?
): unknown
Parameters
Name | Type | Default value |
---|---|---|
value | unknown | undefined |
strategy | CAST_STRATEGY | CAST_STRATEGY.DEFAULT_OR_DROP |
Returns
unknown
Overrides
Defined in
checkRequired
▸ checkRequired(): string
| void
Returns
string
| void
Inherited from
Defined in
checkValidator
▸ checkValidator(value
): void
Parameters
Name | Type |
---|---|
value | unknown |
Returns
void
Inherited from
Defined in
isEmpty
▸ isEmpty(value
): boolean
Parameters
Name | Type |
---|---|
value | unknown |
Returns
boolean
Inherited from
Defined in
isStrictStrategy
▸ isStrictStrategy(strategy
): boolean
Parameters
Name | Type |
---|---|
strategy | VALIDATION_STRATEGY |
Returns
boolean
Inherited from
Defined in
validate
▸ validate(value
, strict?
): unknown
Parameters
Name | Type | Default value |
---|---|---|
value | unknown | undefined |
strict | boolean | true |
Returns
unknown