Skip to content

Latest commit

 

History

History
129 lines (83 loc) · 4.17 KB

sedentary.rst

File metadata and controls

129 lines (83 loc) · 4.17 KB

Sedentary

The base ORM class.

TODO

new Sedentary([options])

Warning

Do not use this constructor directly.

new SedentaryPG(config[, options])

:ref:`SedentaryPG<Sedentary>` uses :xref:`pg.Pool` to connect to the database; please refer to :xref:`pg` and its :xref:`pg-documentation` for details about the config object.

sedentary.connect([sync])

Connects to the database and eventually syncs the schema. The value of the sync argument is ignored unless the :ref:`autoSync<SedentaryOptions.autoSync>` option was set to false when :ref:`new Sedentary<new Sedentary>` was called.

Note

Must be called only once.

sedentary.end()

Closes the connection with the database.

Note

Must be called only once, after :ref:`sedentary.connect()<sedentary.connect>`.

sedentary.model(name, fields[, options [, methods]])

Defines one model. Should be called once for each model/TABLE to be configured.

Note

Must be called before :ref:`sedentary.connect()<sedentary.connect>`.

sedentary.DATETIME()

It is the :ref:`Type function` to specify DATETIME as type for a field.

sedentary.FKEY(attribute, options)

It is the :ref:`Type function` to specify a :ref:`foreign key<Foreign keys>`. It can be either :ref:`Model` or a :ref:`ModelAttribute`. If a :ref:`Model` is provided, its :ref:`primary key` is the target attribute.

sedentary.INT(size)

It is the :ref:`Type function` to specify INT as type for a field. If the value of the size argument is 2, a 16 bit INT :ref:`Type` is returned; if 4, a 32 bit INT :ref:`Type` is returned; no other values are accepted.

sedentary.INT8

It is the :ref:`Type function` to specify 64 bit INT as type for a field. It is a distinct :ref:`Type function` from :ref:`sedentary.INT<sedentary.INT>` to give the attribute a specific type at TypeScript level. TODO

sedentary.VARCHAR(size)

It is the :ref:`Type function` to specify VARCHAR as type for a field. If a value of the size argument is provided, it is the maximum allowed string size at database level.