capacitor-community / sqlite

⚡Capacitor plugin for native & electron SQLite databases.
MIT License
505 stars 121 forks source link

Issue trying to access JSON1 extension #176

Closed adrirrFOS closed 3 years ago

adrirrFOS commented 3 years ago

Hi, I need to store some json fields and I would like to make use of json1 extension. I've been unsuccessful so far. Wondering if it really works with this plugin and if it does, can I have some guidance regarding how to load/use it please?

I am following the angular-sql-app-starter example and replaced some fields with a json content and the data is stored ok. I would like to be able to select using json_each for example

  FROM user, json_each(user.phone)
 WHERE json_each.value LIKE '704-%';```

Package.json
"@capacitor-community/sqlite": "^3.2.2",
"jeep-sqlite": "^1.2.1",

thank you.
jepiqueau commented 3 years ago

@adrirrFOS the Json1 extension is loaded so you should not worry about the load. Have you try the query


SELECT DISTINCT users.name FROM users,
            json_each(users.phone) WHERE json_each.value LIKE '704-%'';

this should work. See angular-sqlite-app-starter testjson1extension.page.ts line 107

adrirrFOS commented 3 years ago

thank you