Liking cljdoc? Tell your friends :D

com.timezynk.mongo.schema

Functions for defining a collection schema.

Functions for defining a collection schema.
raw docstring

anyclj

(any & options)

Field can be of any type.

ParameterDescription
:optional?optional boolean Is the field optional?

Examples

(create-collection! :coll :schema {:field-1 (any)})
Field can be of any type.

| Parameter     | Description |
| ---           | --- |
| `:optional?`  | `optional boolean` Is the field optional? |

**Examples**

```Clojure
(create-collection! :coll :schema {:field-1 (any)})
```
sourceraw docstring

arrayclj

(array <schema>
       &
       :optional?
       <boolean>
       :min-length
       <minimum
       length>
       :max-length
       <maximum
       length>
       :unique?
       <boolean>)

Field must be an array.

ParameterDescription
schemafn A call to a schema function.
:optional?optional boolean Is the field optional?
:min-lengthoptional integer Minimum length of the array.
:max-lengthoptional integer Maximum length of the array.
:unique?optional boolean Whether array values must be unique.

Examples

; field-1 must be an array of strings and contain at least one element:
(create-collection! :coll :schema {:field-1 (array (string) :min-length 1)})
Field must be an `array`.

| Parameter     | Description |
| ---           | --- |
| `schema`      | `fn` A call to a schema function. |
| `:optional?`  | `optional boolean` Is the field optional? |
| `:min-length` | `optional integer` Minimum length of the array. |
| `:max-length` | `optional integer` Maximum length of the array. |
| `:unique?`    | `optional boolean` Whether array values must be unique. |

**Examples**

```Clojure
; field-1 must be an array of strings and contain at least one element:
(create-collection! :coll :schema {:field-1 (array (string) :min-length 1)})
```
sourceraw docstring

booleanclj

(boolean & :optional? <boolean>)

Field must be a boolean.

ParameterDescription
:optional?optional boolean Is the field optional?

Examples

; field-1 must be a boolean and must be included:
(create-collection! :coll :schema {:field-1 (boolean)})
Field must be a `boolean`.

| Parameter    | Description |
| ---          | --- |
| `:optional?` | `optional boolean` Is the field optional? |

**Examples**

```Clojure
; field-1 must be a boolean and must be included:
(create-collection! :coll :schema {:field-1 (boolean)})
```
sourceraw docstring

date-timeclj

(date-time & :optional? <boolean>)

Field must be a java.util.Date object.

ParameterDescription
:optional?optional boolean Is the field optional?

Examples

; Set field-1 to current date and time:
(create-collection! :coll :schema {:field-1 (date-time)})
Field must be a `java.util.Date` object.

| Parameter    | Description |
| ---          | --- |
| `:optional?` | `optional boolean` Is the field optional? |

**Examples**

```Clojure
; Set field-1 to current date and time:
(create-collection! :coll :schema {:field-1 (date-time)})
```
sourceraw docstring

idclj

(id & :optional? <boolean>)

Field must be an ObjectId.

ParameterDescription
:optional?optional boolean Is the field optional?

Examples

; field-1 must be an ObjectId and can be excluded:
(create-collection! :coll :schema {:field-1 (id :optional? true)})
Field must be an `ObjectId`.

| Parameter    | Description |
| ---          | --- |
| `:optional?` | `optional boolean` Is the field optional? |

**Examples**

```Clojure
; field-1 must be an ObjectId and can be excluded:
(create-collection! :coll :schema {:field-1 (id :optional? true)})
```
sourceraw docstring

integerclj

(integer &
         :optional? <boolean>
         :in [<array of accepted values>]
         :min <minimum>
         :max <maximum>)

Field must be an 8-byte long integer.

ParameterDescription
:optional?optional boolean Is the field optional?
:inoptional seq A collection of acceptable values.
:minoptional integer Minimum value.
:maxoptional integer Maximum value.

Examples

; field-1 must be an integer and must be included:
(create-collection! :coll :schema {:field-1 (integer)})
Field must be an 8-byte `long integer`.

| Parameter    | Description |
| ---          | --- |
| `:optional?` | `optional boolean` Is the field optional? |
| `:in`        | `optional seq` A collection of acceptable values. |
| `:min`       | `optional integer` Minimum value. |
| `:max`       | `optional integer` Maximum value. |

**Examples**

```Clojure
; field-1 must be an integer and must be included:
(create-collection! :coll :schema {:field-1 (integer)})
```
sourceraw docstring

mapclj

(map & :optional? <boolean>)

Field must be a map.

ParameterDescription
:optional?optional boolean Is the field optional?

Examples

; Set field-1 to map containing two strings:
(create-collection! :coll :schema {:field-1 (map {:str-1 (string)
                                                  :str-2 (string)})})
Field must be a `map`.

| Parameter    | Description |
| ---          | --- |
| `:optional?` | `optional boolean` Is the field optional? |

**Examples**

```Clojure
; Set field-1 to map containing two strings:
(create-collection! :coll :schema {:field-1 (map {:str-1 (string)
                                                  :str-2 (string)})})
```
sourceraw docstring

numberclj

(number &
        :optional? <boolean>
        :in [<array of accepted values>]
        :min <minimum>
        :max <maximum>)

Field must be an 8-byte double.

ParameterDescription
:optional?optional boolean Is the field optional?
:inoptional seq A collection of acceptable values.
:minoptional integer Minimum value.
:maxoptional integer Maximum value.

Examples

; field-1 must be a number and must be included:
(create-collection! :coll :schema {:field-1 (number)})
Field must be an 8-byte `double`.

| Parameter    | Description |
| ---          | --- |
| `:optional?` | `optional boolean` Is the field optional? |
| `:in`        | `optional seq` A collection of acceptable values. |
| `:min`       | `optional integer` Minimum value. |
| `:max`       | `optional integer` Maximum value. |

**Examples**

```Clojure
; field-1 must be a number and must be included:
(create-collection! :coll :schema {:field-1 (number)})
```
sourceraw docstring

stringclj

(string &
        :optional?
        <boolean>
        :in
        [<array of accepted values>]
        :regex
        <regular
        expression>
        :min-length
        <minimum
        length>
        :max-length
        <maximum
        length>)

Field must be a string.

ParameterDescription
:optional?optional boolean Is the field optional?
:inoptional seq A collection of acceptable values.
:regexoptional string A regular expression that values must pass.
:min-lengthoptional integer Minimum length of the string.
:max-lengthoptional integer Maximum length of the string.

Examples

; field-1 must be a string and must be included:
(create-collection! :coll :schema {:field-1 (string)})
Field must be a `string`.

| Parameter     | Description |
| ---           | --- |
| `:optional?`  | `optional boolean` Is the field optional? |
| `:in`         | `optional seq` A collection of acceptable values. |
| `:regex`      | `optional string` A regular expression that values must pass. |
| `:min-length` | `optional integer` Minimum length of the string. |
| `:max-length` | `optional integer` Maximum length of the string. |

**Examples**

```Clojure
; field-1 must be a string and must be included:
(create-collection! :coll :schema {:field-1 (string)})
```
sourceraw docstring

timestampclj

(timestamp & :optional? <boolean>)

Field must be a timestamp.

ParameterDescription
:optional?optional boolean Is the field optional?

Examples

; field-1 must be an integer and must be included:
(create-collection! :coll :schema {:field-1 (timestamp)})
Field must be a `timestamp`.

| Parameter    | Description |
| ---          | --- |
| `:optional?` | `optional boolean` Is the field optional? |

**Examples**

```Clojure
; field-1 must be an integer and must be included:
(create-collection! :coll :schema {:field-1 (timestamp)})
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close