Skip to content

Commit 3469f2b

Browse files
committed
v.0.0.7 - Update docs
1 parent 61b29fa commit 3469f2b

File tree

2 files changed

+60
-24
lines changed

2 files changed

+60
-24
lines changed

README.md

Lines changed: 57 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/fernandocode/ionic-database-builder/issues)
33

44
# ionic-database-builder
5-
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'.
66

77
# Getting Started
88

@@ -14,6 +14,10 @@ npm install --save ionic-database-builder
1414
```
1515
This will install the current stable version of `ionic-database-builder` in your `node_modules` directory and save the entry in `package.json`.
1616

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+
1721
### Step 2: Add Module in App and Settings
1822

1923
#### Simple Setup
@@ -25,31 +29,46 @@ import { DatabaseHelper } from 'database-builder';
2529
@NgModule({
2630
...
2731
imports: [
28-
DatabaseModule.forRootValue(
29-
// object to simple settings database
30-
new DatabaseSettingsFactoryDefault(
31-
1, // version database
32-
"database1", // name database
33-
// mapper for database
34-
new MappersTableSimple(new DatabaseHelper(), {
32+
DatabaseModule.forRoot(
33+
{// settings database: name, version and mapper
34+
useValue: // object to simple settings database
35+
new DatabaseSettingsFactoryDefault(
36+
1, // version database
37+
"database1", // name database
38+
// mapper for database
39+
new MappersTableSimple(new DatabaseHelper(), {
3540
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
3742
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"
3944
referencesIdRecursive: false, // if "true" generate column for id reference recursive for all references inner.
4045
referencesIdColumn: "id" // name id column references
41-
})
42-
.mapper(
43-
false, // readonly
44-
void 0, // keyColumn: default "id"
45-
void 0, // default settings constructor
46-
// Type models for mapper
47-
TestClazz,
48-
TestClazzRef
49-
)),
46+
})
47+
.mapper(
48+
false, // readonly
49+
void 0, // keyColumn: default "id"
50+
void 0, // 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+
},
5069
// implementation of "DatabaseMigrationContract" to estrategy migration upgrade versions database
5170
DatabaseMigrationService
52-
)
71+
),
5372
...
5473
],
5574
...
@@ -107,9 +126,25 @@ import { DatabaseModule } from 'ionic-database-builder';
107126
...
108127
imports: [
109128
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+
return platform.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
111146
DatabaseMigrationService
112-
)
147+
),
113148
...
114149
],
115150
...

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"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'.",
55
"main": "index.js",
66
"scripts": {
77
"ng": "ng",
@@ -19,6 +19,7 @@
1919
},
2020
"keywords": [
2121
"ionic",
22+
"angular",
2223
"orm",
2324
"database",
2425
"builder",

0 commit comments

Comments
 (0)