View Source MongoAgile.MapSchema.IdObjectType (mongo_agile v0.8.1-rc)

You can use this customtype of MapSchema for can use BSON_ID, and parse to json easily.

Link to this section Summary

Functions

Cast string id to bson_id object.

Check it´s valid id

Callback implementation for MapSchema.CustomType.name/0.

Callback implementation for MapSchema.CustomType.nested?/0.

Link to this section Functions

@spec cast(any()) :: any() | :error

Cast string id to bson_id object.

example

Example:

iex> alias MongoAgile.MapSchema.IdObjectType iex> str_id = "5feaeb1e10fb18469bbd7336" iex> bson_id = BSON.ObjectId.decode!(str_id) iex> IdObjectType.cast(str_id) == bson_id true

iex> alias MongoAgile.MapSchema.IdObjectType iex> bson_id = BSON.ObjectId.decode!("5feaeb1e10fb18469bbd7336") iex> IdObjectType.cast(bson_id) == bson_id true

@spec doctest_values() :: [{any(), any()}]

Callback implementation for MapSchema.CustomType.doctest_values/0.

@spec is_valid?(any()) :: boolean()

Check it´s valid id

example

Example:

iex> alias MongoAgile.MapSchema.IdObjectType iex> bson_id = BSON.ObjectId.decode!("5feaeb1e10fb18469bbd7336") iex> IdObjectType.is_valid?(bson_id) true

Callback implementation for MapSchema.CustomType.name/0.

Callback implementation for MapSchema.CustomType.nested?/0.