You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can access the database instance directly by `orm.db`. If you are using an existing database and it contains JSON objects, enable `jsonCompatMode` in options or objects similar to:
11
+
You can access the database instance directly by `orm.db`. If you are using an existing database and it contains JSON objects, enable `jsonCompatMode` in options or objects similar to following will not be parsed.
12
12
```json
13
13
{
14
14
"foo": "baz",
15
15
"bar": 0
16
16
}
17
17
```
18
-
will not be parsed.<br>
19
18
20
19
**Create a model:**
21
20
```typescript
@@ -26,11 +25,10 @@ class Foo extends SqlTable {
26
25
```
27
26
Incase `Foo` exists in the database but has a different name, use `@orm.model('bar')`. All Tables have `id` as a primary key.
28
27
It can be removed by overriding it and using `@orm.ignoreColumn()`. Tables are created if they don't exist. If new columns
29
-
are added, the table is altered. If a column is removed from the model, it still stays in the database. If you want to renamed
30
-
a column use `@orm.mappedTo('oldName')`
28
+
are added, the table is altered. If a column is removed from the model, it still stays in the database. If you want to rename the property, or the column exists with a different name use `@orm.mappedTo('oldName')`
31
29
32
30
**Defining columns:**<br>
33
-
All properties of the table are considered as columns. Column types are autmatically inferred from the default value<br>
31
+
All properties of the table are considered as columns. Column types are automatically inferred from the default value<br>
34
32
of the property.
35
33
```typescript
36
34
classFooextendsSqlTable {
@@ -39,7 +37,7 @@ class Foo extends SqlTable {
39
37
// type is automatically inferred as "string"
40
38
public foo ='bar'
41
39
42
-
// column type is required when property doesnt have a default value
40
+
// column type is required when property doesn't have a default value
43
41
@orm.columnType('string')
44
42
public bar!:string
45
43
@@ -65,7 +63,7 @@ class Foo extends SqlTable {
65
63
@orm.mappedTo('bar')
66
64
public baa =''
67
65
68
-
// if you dont want to stack multiple decorators, you can do:
66
+
// if you don't want to stack multiple decorators, you can do:
69
67
@orm.column({ type: 'string', nullable: true })
70
68
public faz!:string|null
71
69
}
@@ -86,7 +84,7 @@ orm.findOne(Foo, {
86
84
// you can check if its new from `Foo._new`
87
85
orm.findOneOptional(Foo, 1)
88
86
89
-
// same as `findOne` but returns multiple instanceof/rows of Foo
87
+
// same as `findOne` but returns multiple instances of or rows of Foo
0 commit comments