Skip to content

Commit 5d2f4b4

Browse files
authored
implement jsonObject dialect (#101)
* implement jsonObject dialect * fix lint errors * validate json objects * add before and after execute events * update readme * 2.9.0
1 parent fa98f7f commit 5d2f4b4

18 files changed

Lines changed: 330 additions & 44 deletions

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ jsconfig.json
1010
.gitpod.yml
1111
.gitpod.dockerfile
1212

13+
# docs
14+
docs
15+
1316
#github
1417
.github
1518

README.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
![GitHub last commit](https://img.shields.io/github/last-commit/themost-framework/sqlite)
77
![GitHub Release Date](https://img.shields.io/github/release-date/themost-framework/sqlite)
88
[![npm](https://img.shields.io/npm/dw/@themost/sqlite)](https://www.npmjs.com/package/@themost%2Fsqlite)
9-
![Snyk Vulnerabilities for npm package](https://img.shields.io/snyk/vulnerabilities/npm/@themost/sqlite)
109

1110
![MOST Web Framework Logo](https://github.com/themost-framework/common/raw/master/docs/img/themost_framework_v3_128.png)
1211

@@ -40,16 +39,32 @@ Register SQLite adapter on app.json as follows:
4039
]
4140
}
4241

42+
or create a new instance of `SqliteAdapter` class for connecting to SQLite database.
4343

44-
#### Post Installation Note:
45-
SQLite Data Adapter comes with a regular expression extension for SQLite (regexp.c). You have to compile this extension as follows:
44+
```javascript
45+
const { SqliteAdapter } = require('@themost/sqlite');
46+
const { QueryExpression } = require('@themost/query');
47+
const db = new SqliteAdapter({
48+
database: 'db/local.db'
49+
});
50+
const query = new QueryExpression()
51+
.select(({ id, name, category, model, price }) => ({
52+
id,
53+
name,
54+
category,
55+
model,
56+
price,
57+
})).from('ProductData')
58+
.where((x) => {
59+
return x.price > 500 && x.category === "Laptops";
60+
})
61+
.orderByDescending((x) => x.price)
62+
.take(10);
63+
```
4664

47-
##### Using GCC/MinGW on Windows and Linux
48-
gcc -shared -fPIC -Isqlite3 -o regexp.0.dylib regexp.c
65+
Read more about [MOST Web Framework query language provided by @themost/query](https://github.com/themost-framework/query?#themostquery)
4966

50-
##### Using GCC on Mac OSX
51-
gcc -dynamiclib -fPIC -Isqlite3 -o regexp.0.dylib regexp.c
67+
Use [query playground project at codesanbox.io](https://codesandbox.io/p/devbox/query-playground-zc8fg9) to learn more about the query language specification of [@themost-framework](https://github.com/themost-framework)
5268

53-
##### Microsoft Tools on Windows
54-
cl /Gd regexp.c /I sqlite3 /DDLL /LD /link /export:sqlite3_extension_init /out:regexp.0.dylib
69+
![codesandbox.io_query-playground-1.png](docs/img/codesandbox.io_query-playground-1.png)
5570

babel.config.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,12 @@ module.exports = {
99
}
1010
]
1111
],
12+
plugins: [
13+
[
14+
'@babel/plugin-proposal-decorators',
15+
{
16+
'legacy': true
17+
}
18+
]
19+
]
1220
};
493 KB
Loading
450 KB
Loading

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const config = {
1919
// clearMocks: false,
2020

2121
// Indicates whether the coverage information should be collected while executing the test
22-
// collectCoverage: false,
22+
collectCoverage: true,
2323

2424
// An array of glob patterns indicating a set of files for which coverage information should be collected
2525
// collectCoverageFrom: undefined,

jest.setup.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
process.env.NODE_ENV='development';
1+
require('dotenv').config();
2+
const { JsonLogger } = require('@themost/json-logger');
3+
const { TraceUtils } = require('@themost/common');
4+
process.env.NODE_ENV = 'development';
5+
TraceUtils.useLogger(new JsonLogger());
26
/* global jest */
37
jest.setTimeout(30000);

jsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
33
"baseUrl": ".",
4+
"experimentalDecorators": true,
45
"paths": {
56
"@themost/sqlite": [
67
"src/index"

package-lock.json

Lines changed: 86 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@themost/sqlite",
3-
"version": "2.8.4",
3+
"version": "2.9.0",
44
"description": "MOST Web Framework SQLite Adapter",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",
@@ -28,6 +28,7 @@
2828
"sqleanVersion": "0.27.1"
2929
},
3030
"dependencies": {
31+
"@themost/events": "^1.5.0",
3132
"async": "^2.6.4",
3233
"sprintf-js": "^1.1.2",
3334
"sqlite3": "^5.1.7",
@@ -41,15 +42,16 @@
4142
"@babel/core": "^7.26.0",
4243
"@babel/eslint-parser": "^7.25.9",
4344
"@babel/eslint-plugin": "^7.25.1",
45+
"@babel/plugin-proposal-decorators": "^7.25.9",
4446
"@babel/preset-env": "^7.26.0",
4547
"@babel/register": "^7.25.9",
4648
"@rollup/plugin-babel": "^5.3.1",
4749
"@rollup/plugin-commonjs": "^22.0.0",
4850
"@themost/common": "^2.11.0",
49-
"@themost/data": "^2.14.2",
50-
"@themost/events": "^1.3.0",
51+
"@themost/data": "^2.18.1",
52+
"@themost/json-logger": "^1.1.0",
5153
"@themost/peers": "^1.0.2",
52-
"@themost/query": "^2.14.5",
54+
"@themost/query": "^2.14.7",
5355
"@themost/xml": "^2.5.2",
5456
"@types/jasmine": "^5.1.4",
5557
"dotenv": "^16.0.0",

0 commit comments

Comments
 (0)