-
Hi, there; My code looks like this:
where the "dbJson" is imported from a valid Json data schema file. I tried another Json schema file which works well in my another project with plugin version 4.1.0, but version 4.6.0 gives the error. Then I tried using the sample data which is jsonSQLite object in "https://github.com/capacitor-community/sqlite/blob/master/docs/ImportExportJson.md", then tested in the code below which works ok: Test 2:
where the "dataToImport" is the sample data (jsonSQLite object) provided in the above link. Not finished yet. Then I replaced the Json file with the string generated from JSON.stringify(dataToImport) and then retried from my code in "Test 1", Can some please help this? Cheers, |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 2 replies
-
hi, can you show a bit more code I may assume that of(dbJson) is an observable so can you give how it is define? |
Beta Was this translation helpful? Give feedback.
-
@storynana i am away from any computer till Sunday i will have a look after this. In the mean time you can have a look to angular-sqlite-starter-app on https://github.com/jepiqueau there is some example of import export json under the tests folder |
Beta Was this translation helpful? Give feedback.
-
Thanks Jean.
No hush. Will check it out.
…On Fri, Jan 13, 2023 at 8:47 PM QUEAU Jean Pierre ***@***.***> wrote:
@storynana <https://github.com/storynana> i am away from any computer
till Sunday i will have a look after this. In the mean time you can have a
look to angular-sqlite-starter-app on https://github.com/jepiqueau there
is some example of import export json under the tests folder
—
Reply to this email directly, view it on GitHub
<#369 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACQQ76TX4NTC5EOVS2OJZ7LWSECCFANCNFSM6AAAAAATYTHCRU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
--
Cheers,
qiuwei
|
Beta Was this translation helpful? Give feedback.
-
@storynana Thank for waiting
and i got in the console
meaning that it works fine. |
Beta Was this translation helpful? Give feedback.
-
Hi, Jean Pierre;
Thanks Jean for this response.
Yes, I tried it again with the same config in the tsconfig.json and
it gives the same error.
Can you please check your @capacitor-community plugin version number,
my one is sqlite 4.6.0
;
[image: image.png]
My other project runs version 4.1.0 which works fine.
[image: image.png]
Cheers,
Qiuwei
…On Tue, Jan 17, 2023 at 7:40 AM QUEAU Jean Pierre ***@***.***> wrote:
@storynana <https://github.com/storynana> Thank for waiting
i did that
- copy the testData-schema.db.txt
<https://github.com/capacitor-community/sqlite/files/10406064/testData-schema.db.txt>
in the assets/databases folder of one of my app and rename it as .json file
- add in the tsconfig.json inside the compilerOptions
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
- edit my home page with
...
import { of } from 'rxjs';
import dbJson from 'src/assets/databases/testData-schema.db.json';
import { JsonSQLite, CapacitorSQLite } from ***@***.***/sqlite';
...
ngOnInit() {
...
of(dbJson).subscribe(
async (jsonExport: JsonSQLite) => {
const jsonstring = JSON.stringify(jsonExport);
console.log(jsonstring);
const isValid = await CapacitorSQLite.isJsonValid({ jsonstring: jsonstring });
console.log(`-- after is JsonValid isValid.result: ${isValid.result}`);
if (isValid.result) {
console.log("--------before-------");
await CapacitorSQLite.importFromJson({ jsonstring });
console.log("--------after-------");
}
});
...
}
and i got in the console
home.page.ts:35 {"database":"db-from-json","version":1,"encrypted":false,"mode":"full","tables":[{"name":"users","schema":[{"column":"id","value":"INTEGER PRIMARY KEY NOT NULL"},{"column":"email","value":"TEXT UNIQUE NOT NULL"},{"column":"name","value":"TEXT"},{"column":"age","value":"INTEGER"},{"column":"sql_deleted","value":"BOOLEAN DEFAULT 0 CHECK (sql_deleted IN (0, 1))"},{"column":"last_modified","value":"INTEGER DEFAULT (strftime('%s', 'now'))"}],"indexes":[{"name":"index_user_on_name","value":"name"},{"name":"index_user_on_last_modified","value":"last_modified DESC"},{"name":"index_user_on_email_name","value":"email ASC, ***@***.******@***.***","Brown",15,0,1590383895]]},{"name":"messages","schema":[{"column":"id","value":"INTEGER PRIMARY KEY NOT NULL"},{"column":"userid","value":"INTEGER"},{"column":"title","value":"TEXT NOT NULL"},{"column":"body","value":"TEXT NOT NULL"},{"column":"sql_deleted","value":"BOOLEAN DEFAULT 0 CHECK (sql_deleted IN (0, 1))"},{"column":"last_modified","value":"INTEGER DEFAULT (strftime('%s', 'now'))"},{"foreignkey":"userid","value":"REFERENCES users(id) ON DELETE CASCADE"}],"indexes":[{"name":"index_messages_on_title","value":"title"},{"name":"index_messages_on_last_modified","value":"last_modified DESC"}],"values":[[1,1,"test post 1","content test post 1",0,1587310030],[2,2,"test post 2","content test post 2",0,1590388125],[3,1,"test post 3","content test post 3",0,1590383895]]},{"name":"images","schema":[{"column":"id","value":"INTEGER PRIMARY KEY NOT NULL"},{"column":"name","value":"TEXT UNIQUE NOT NULL"},{"column":"type","value":"TEXT NOT NULL"},{"column":"size","value":"INTEGER"},{"column":"img","value":"BLOB"},{"column":"sql_deleted","value":"BOOLEAN DEFAULT 0 CHECK (sql_deleted IN (0, 1))"},{"column":"last_modified","value":"INTEGER DEFAULT (strftime('%s', 'now'))"}],"indexes":[{"name":"index_images_on_last_modified","value":"last_modified DESC"}],"values":[[1,"meowth","png","NULL","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACgAAAAkCAYAAAD7PHgWAAAEcElEQVRYR8WYP2hTQRzHfx10aQchi0JcLGpBSBcrlTrpIjoFiy6FDipOHVz8Q0HrUGxdg1N1KBRBackiVoQ6FMVIuzQgpEpdjOiSLUXQIfK9976X37t3l6RNxVuS3Hvv7nPf3+/3vcvraTQaDdlFK4z3yMT8rh7d0Ww97QAzfX12wFq9br4buOk7UpicaQm5F4toCajh9LKnLm23Bex0Ee3k7ArwS/mVvH5elqEzzWmGr0dhDwGGFs3ouMAdA7491y+Dhw5KZuG9UEEA1r6XZfhUPOxgQ0pzPQJIDTi11NtOKOkKkHCcpfDrjQlxaXnGdFE1fAcg2to7sWmgAfVYWCzbPwO06imNHt0Tyd/IyfDlrYRy7kI3fvyUsyvRPbsCxIPIGQ6MAdFWD5RbKnjxZhTSWn0+AqyuS2agEPWNjZhPjrUngBgQkABDQ3hNOJdnmvkXa5UZ6W2CxXBaRoBiLLR2cLgnUSRIbOSLlptVx8LQk7k5iHutah44Pks12+VfApBVh04YsAbV1yR7sslYXU+oSPUK46NWZWPmseJdATLfTJ5UJsxYBNXqoc+EeX7RgpbmRmX1pcjsS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R5ccllPAAAAU1QTFRFNjtAQEVK////bG9zSk9T/v7+/f39/f3+9vf3O0BETlJWNzxB/Pz8d3t+TFFVzM3O1NXX7u/vUldbRElNs7W3v8HCmZyeRkpPW19j8vLy7u7vvsDC9PT1cHR3Oj9Eo6WnxsjJR0tQOD1Bj5KVgYSHTVFWtri50dLUtLa4YmZqOT5D8vPzRUpOkZOWc3Z64uPjr7Gzuru95+jpX2NnaGxwPkNHp6mrioyPlZeadXh8Q0hNPEBFyszNh4qNc3d6eHx/OD1Cw8XGXGBkfoGEra+xxcbIgoaJu72/m52ggoWIZ2tu8/P0wcLE+vr7kZSXgIOGP0NIvr/BvL6/QUZKP0RJkpWYpKaoqKqtVVldmJqdl5qcZWhstbe5bHB0bnJ1UVVZwsTF5ubnT1RYcHN3oaSm3N3e3NzdQkdLnJ+h9fX1TlNX+Pj47/DwwsPFVFhcEpC44wAAAShJREFUeNq8k0VvxDAQhZOXDS52mRnKzLRlZmZm+v/HxmnUOlFaSz3su4xm/BkGzLn4P+XimOJZyw0FKufelfbfAe89dMmBBdUZ8G1eCJMba69Al+AABOOm/7j0DDGXtQP9bXjYN2tWGQfyA1Yg1kSu95x9GKHiIOBXLcAwUD1JJSBVfUbwGGi2AIvoneK4bCblSS8b0RwwRAPbCHx52kH60K1b9zQUjQKiULbMDbulEjGha/RQQFDE0/ezW8kR3C3kOJXmFcSyrcQR7FDAi55nuGABZkT5hqpk3xughDN7FOHHHd0LLU9qtV7r7uhsuRwt6pEJJFVLN4V5CT+SErpXt81DbHautkpBeHeaqNDRqUA0Uo5GkgXGyI3xDZ/q/wJMsb7/pwADAGqZHDyWkHd1AAAAAElFTkSuQmCC",0,1590389895]]}]}
home.page.ts:37 -- after is JsonValid isValid.result: true
home.page.ts:39 --------before-------
home.page.ts:41 --------after-------
meaning that it works fine.
i also checked that the database db-from-jsonSQLite.db was created
—
Reply to this email directly, view it on GitHub
<#369 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACQQ76T3J2RD5MQQ76UJUNTWSWI2ZANCNFSM6AAAAAATYTHCRU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
--
Cheers,
qiuwei
|
Beta Was this translation helpful? Give feedback.
-
@storynana did you modify the import too. nothing as changed between 4.6.0 and 4.6.1-2 regarding the json object and the import export json. On which plaform are you running? There is nothing i can do more on this as i cannot reproduce the error. The last thing you can do is to share your app on github so i may have a look |
Beta Was this translation helpful? Give feedback.
-
Hi, Jean;
It is Ionic, Angular:
[image: image.png]
Thanks Jean for the effort put on this.
Currently I can still use jsonSQLite to import the data schema.
Thanks again.
Cheers,
Qiuwei
…On Tue, Jan 17, 2023 at 8:19 PM QUEAU Jean Pierre ***@***.***> wrote:
@storynana <https://github.com/storynana> did you modify the import too.
nothing as changed between 4.6.0 and 4.6.1-2 regarding the json object and
the import export json. On which plaform are you running? There is nothing
i can do more on this as i cannot reproduce the error. The last thing you
can do is to share your app on github so i may have a look
—
Reply to this email directly, view it on GitHub
<#369 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACQQ76UUFZJ7DJTS4EI3OKLWSZBXFANCNFSM6AAAAAATYTHCRU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
--
Cheers,
qiuwei
|
Beta Was this translation helpful? Give feedback.
-
@storynana i was asking for which platform Web, Android, iOS, Electron ? |
Beta Was this translation helpful? Give feedback.
-
HI, Jean;
The current project I am working on is currently on the Web, Chrome.
Another project is Android. The isJsonValid method works for both Web
and Android.
Cheers,
Qiuwei
…On Tue, Jan 17, 2023 at 10:41 PM QUEAU Jean Pierre ***@***.***> wrote:
@storynana <https://github.com/storynana> i was asking for which platform
Web, Android, iOS, Electron ?
—
Reply to this email directly, view it on GitHub
<#369 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACQQ76WJPD5ZE76HZA376OTWSZSMDANCNFSM6AAAAAATYTHCRU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***
com>
--
Cheers,
qiuwei
|
Beta Was this translation helpful? Give feedback.
@storynana Thank for waiting
i did that
tsconfig.json
inside thecompilerOptions