sumo

Main module for sumo.

Main module for sumo. Use this one from your own applications.

Copyright 2012 Inaka <hello@inaka.net>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Types


condition() =
            {'and', [condition()]} |
            {'or', [condition()]} |
            {'not', condition()} |
            {field_name(), field_value()} |
            {field_name(), operator(), field_value()} |
            {field_name(), operator(), field_name()}

conditions() = condition() | [condition()]

field_attr() =
            id |
            unique |
            index |
            not_null |
            auto_increment |
            {length, integer()}

field_attrs() = [field_attr()]

field_name() = atom()

field_type() =
            integer | string | binary | text | float | date | datetime

field_value() = term()

operator() = '<' | '>' | '==' | '=<' | '>=' | '/=' | like

schema_name() = atom()

sort_order() = asc | desc

user_doc() = term()

Functions


create_schema() -> ok

Creates the schema for all known (configured) docs.

find_one(DocName::schema_name(), Conditions::conditions()) -> user_doc() | notfound

Returns 1 doc that matches the given Conditions.

find(DocName::schema_name(), Id::field_value()) -> user_doc() | notfound

Returns the doc identified by Id.

find_all(DocName::schema_name()) -> [user_doc()]

Returns all docs from the given store.

find_all(DocName::schema_name(), SortFields0::sort(), Limit::non_neg_integer(), Offset::non_neg_integer()) -> [user_doc()]

Returns Limit docs from the given store, starting at offset.

find_by(DocName::schema_name(), Conditions::conditions()) -> [user_doc()]

Returns *all* docs that match Conditions.

find_by(DocName::schema_name(), Conditions::conditions(), Limit::non_neg_integer(), Offset::non_neg_integer()) -> [user_doc()]

Returns Limit number of docs that match Conditions, starting at offset Offset.

find_by(DocName::schema_name(), Conditions::conditions(), SortFields0::sort(), Limit::non_neg_integer(), Offset::non_neg_integer()) -> [user_doc()]

Returns Limit number of docs that match Conditions, starting at offset Offset.

persist(DocName::schema_name(), UserDoc) -> UserDoc

Creates or updates the given Doc.

delete_all(DocName::schema_name()) -> non_neg_integer()

Deletes all docs of type DocName.

delete(DocName::schema_name(), Id::user_doc()) -> boolean()

Deletes the doc identified by Id.

delete_by(DocName::schema_name(), Conditions::conditions()) -> non_neg_integer()

Deletes the doc identified by Conditions.

create_schema(DocName::schema_name()) -> ok

Creates the schema for the docs of type DocName.

create_schema(DocName::schema_name(), Store::atom()) -> ok

Creates the schema for the docs of type DocName using the given store.

call(DocName::schema_name(), Function::atom()) -> term()

Calls the given custom function of a store.

call(DocName::schema_name(), Function::atom(), Args::[term()]) -> term()

Calls the given custom function of a store with the given args.

new_schema(Name::schema_name(), Fields::[field()]) -> schema()

Returns a new schema.

new_field(Name::field_name(), Type::field_type(), Attributes::field_attrs()) -> field()

Returns a new field of the given type and attributes.

new_field(Name::field_name(), Type::field_type()) -> field()

Returns a new field of the given type without attributes.