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
Extended library from [database-builder](https://github.com/fernandocode/database-builder) to assist in creating and maintaining SQL commands with integrate execute commands in[SQLite ('@ionic-native/sqlite')](https://ionicframework.com/docs/native/sqlite/).
5
+
Extended library from [database-builder](https://github.com/fernandocode/database-builder) to assist in creating and maintaining SQL commands. Allowing integrate execute commands with[SQLite ('@ionic-native/sqlite')](https://ionicframework.com/docs/native/sqlite/), [Web Sql](https://www.w3.org/TR/webdatabase/), [Indexed Database](https://www.w3.org/TR/IndexedDB/), etc. Through the interface injection 'DatabaseCreatorContract' returning an implementation of 'DatabaseObject'.
This will install the current stable version of `ionic-database-builder` in your `node_modules` directory and save the entry in `package.json`.
16
16
17
+
#### Step 1.1: If it will be used with SQLite plugin install:
18
+
19
+
[Install as instructed.](https://ionicframework.com/docs/native/sqlite/)
20
+
17
21
### Step 2: Add Module in App and Settings
18
22
19
23
#### Simple Setup
@@ -25,31 +29,46 @@ import { DatabaseHelper } from 'database-builder';
25
29
@NgModule({
26
30
...
27
31
imports: [
28
-
DatabaseModule.forRootValue(
29
-
// object to simple settings database
30
-
newDatabaseSettingsFactoryDefault(
31
-
1, // version database
32
-
"database1", // name database
33
-
// mapper for database
34
-
newMappersTableSimple(newDatabaseHelper(), {
32
+
DatabaseModule.forRoot(
33
+
{// settings database: name, version and mapper
34
+
useValue: // object to simple settings database
35
+
newDatabaseSettingsFactoryDefault(
36
+
1, // version database
37
+
"database1", // name database
38
+
// mapper for database
39
+
newMappersTableSimple(newDatabaseHelper(), {
35
40
references: false, // if "true" generate column for serialize object reference to JSON.
36
-
// Example in "TestClazz", create column "testClazzRef" to serialize "TestClazzRef" object
41
+
// Example in "TestClazz", create column "testClazzRef" to serialize "TestClazzRef" object
37
42
referencesId: true, // if "true" generate column for id reference.
38
-
// Example in "TestClazz", create column "testClazzRef_id" to save "TestClazzRef" property "id"
43
+
// Example in "TestClazz", create column "testClazzRef_id" to save "TestClazzRef" property "id"
39
44
referencesIdRecursive: false, // if "true" generate column for id reference recursive for all references inner.
40
45
referencesIdColumn: "id"// name id column references
41
-
})
42
-
.mapper(
43
-
false, // readonly
44
-
void0, // keyColumn: default "id"
45
-
void0, // default settings constructor
46
-
// Type models for mapper
47
-
TestClazz,
48
-
TestClazzRef
49
-
)),
46
+
})
47
+
.mapper(
48
+
false, // readonly
49
+
void0, // keyColumn: default "id"
50
+
void0, // default settings constructor
51
+
// Type models for mapper
52
+
TestClazz,
53
+
TestClazzRef
54
+
))
55
+
},
56
+
{// is available database in context
57
+
// As SQLite is only available on the platform cordova this is used to verify this parameter
58
+
// useFactory: (platform: Platform) => {
59
+
// return platform.is("cordova");
60
+
// },
61
+
// deps: [Platform],
62
+
// or simply can pass true without conditions
63
+
useValue: true
64
+
},
65
+
{
66
+
// Declare the implementation of 'DatabaseCreatorContract' that you want to use, you can include a proxy, use libraries with different signatures, or create mocks for tests, etc.
67
+
useClass: SQLite
68
+
},
50
69
// implementation of "DatabaseMigrationContract" to estrategy migration upgrade versions database
51
70
DatabaseMigrationService
52
-
)
71
+
),
53
72
...
54
73
],
55
74
...
@@ -107,9 +126,25 @@ import { DatabaseModule } from 'ionic-database-builder';
107
126
...
108
127
imports: [
109
128
DatabaseModule.forRoot(
110
-
DatabaseSettingsFactory,
129
+
{// settings database: name, version and mapper
130
+
useClass: DatabaseSettingsFactory
131
+
},
132
+
{// is available database in context
133
+
// As SQLite is only available on the platform cordova this is used to verify this parameter
134
+
useFactory: (platform:Platform) => {
135
+
returnplatform.is("cordova");
136
+
},
137
+
deps: [Platform],
138
+
// // or simply can pass true without conditions
139
+
// useValue: true
140
+
},
141
+
{
142
+
// Declare the implementation of 'DatabaseCreatorContract' that you want to use, you can include a proxy, use libraries with different signatures, or create mocks for tests, etc.
143
+
useClass: SQLite
144
+
},
145
+
// implementation of "DatabaseMigrationContract" to estrategy migration upgrade versions database
Copy file name to clipboardExpand all lines: package.json
+3-2Lines changed: 3 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
{
2
2
"name": "ionic-database-builder",
3
-
"version": "0.0.6",
4
-
"description": "Extended library from database-builder to assist in creating and maintaining SQL commands with integrate execute commands in SQLite ('@ionic-native/sqlite').",
3
+
"version": "0.0.7",
4
+
"description": "Extended library from database-builder to assist in creating and maintaining SQL commands. Allowing integrate execute commands with SQLite ('@ionic-native/sqlite'), Web Sql, Indexed Database, etc. Through the interface injection 'DatabaseCreatorContract' returning an implementation of 'DatabaseObject'.",
0 commit comments