Models
Models.
This module provides:
Model
: Converting Python classes into Ramifice Models.model
: Decorator for converting Python classes into Ramifice models.
Model Parameters¶
( only service_name
is a required parameter )
Parameter | Default | Description |
---|---|---|
service_name | no | Examples: Accounts | Smartphones | Washing machines | etc ... |
fixture_name | None |
The name of the fixture in the config/fixtures directory (without extension).
Examples: SiteSettings | AppSettings | etc ... |
db_query_docs_limit | 1000 | limiting query results. |
is_create_doc | True |
Can a Model create new documents in a collection? Set to False if you only need one document in the collection and the Model is using a fixture. |
is_update_doc | True | Can a Model update documents in a collection? |
is_delete_doc | True | Can a Model remove documents from a collection? |
Example:
@model(
service_name="ServiceName",
fixture_name="FixtureName",
db_query_docs_limit=1000,
is_create_doc = True,
is_update_doc = True,
is_delete_doc = True,
)
class User:
def fields(self):
self.username = TextField(
label=gettext("Username"),
required=True,
unique=True,
)