@laboratoria/sdk-js 3.4.0 → 4.0.0-alpha.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md CHANGED
@@ -45,6 +45,63 @@ app.auth.signIn(email, password);
45
45
  app.auth.signOut();
46
46
  ```
47
47
 
48
+ ### Models
49
+
50
+ The `app` object exposes data models used to access data. Each model represents
51
+ a _type_ of object, which is stored in a database table.
52
+
53
+ All models have the following methods and properties.
54
+
55
+ #### CRUD methods
56
+
57
+ * `create`
58
+ * `delete`
59
+ * `findById`
60
+ * `findMany`
61
+ * `update`
62
+ * `upsert`
63
+
64
+ #### Other methods
65
+
66
+ * `parse`
67
+ * `stats`
68
+ * `validate`
69
+ * `validateAttr`
70
+
71
+ #### Properties
72
+
73
+ * `relations`
74
+ * `schema`
75
+
76
+ ### Model Schema
77
+
78
+ Each _model_ has a _schema_ (`model.schema`) that describes the _shape_ of the
79
+ data, what properties (columns) it has, what data types these columns are,
80
+ whether they are _required_ or not, etc.
81
+
82
+ The `model.schema` is an object with the following properties:
83
+
84
+ * `inputProps`: An array listing properties to be taken into account when
85
+ building input UI or sending data (via `model.create`, `model.update`, etc).
86
+ * `primaryKey`: Primary key in the underlying table.
87
+ * `properties`: An object with the model properties. Each property is described
88
+ by an object having the following keys:
89
+ - `type`: It can be: `boolean`, `integer`, `string`, `date` o una referncia a
90
+ un modelo, en cuyo caso el string será el nombre del modelo de prisma.
91
+ - `default`
92
+ - `enum`
93
+ - `format`: `date-time`
94
+ - `$ref`
95
+ - `anyOf`
96
+ - `items`
97
+ - `inputType`
98
+ - `isRequired`
99
+ - `isScalar`
100
+ - `isRef`
101
+ * `type`: The schema for the whole model will always be of type `object`.
102
+
103
+ ***
104
+
48
105
  ### Users
49
106
 
50
107
  ```js