Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 44 lines (36 sloc) 1.93 kb
b00bdd3 Updated development documentation somewhat.
Zef Hemel authored
1 Documentation for developers
2 ============================
3
4 Constructor functions
5 ---------------------
6
7 var Task = persistence.define('Task', {
8 name: "TEXT",
9 done: "BOOL"
10 });
11 var Category = persistence.define('Category', {
12 name: "TEXT"
13 });
14 Task.hasOne('category', Category);
15
16 `Task` is a constructor function that is used to create new instances of the `Task` entity, but also can be used to retrieve meta data from, using `Task.meta`. This `meta` field provides the following information:
17
18 * `name`, the name of the entity as set as first argument of `define`
19 * `fields`, the field object passed to the original `define`,
20 consisting of property names as keys and textual column types as
21 values.
22 * `hasOne`, an object with relation names as keys and relationship
23 objects as values. The relationship object currently has one field:
24 `type`: which links to the constructor function of the type of the
25 relation. Example: `Task.hasOne.category.type` will equal the
26 `Category` constructor.
27 * `hasMany`, an object with relation anmes as keys and relationship objects as values. The relationship has the following fields:
28 * `type`: the constructor function of the relationship entity
29 * `inverseProperty`: the property name of the inverse relation
30 * `manyToMany`: a boolean value indicating if this is a manyToMany
31 relationship or not (then it's a one-tomany)
32 * `tableName`: name of the utility coupling table used for a
33 many-to-many relationship
34
35 Extension hooks
36 ----------------
37
38 * `persistence.entityDecoratorHooks`: a list of functions (with the
39 constructor function as argument) to be called to decorate. Useful to
40 add new functionality to constructo functions, such as `Task.index`.
41 * `persistence.flushHooks`: a list of functions to be called before flushing.
42 * `persistence.schemaSyncHooks`: a list of functions to be called before syncing the schema.
792501e @zefhemel Working on selectJSON, refactoring some code.
zefhemel authored
43
Something went wrong with that request. Please try again.