oak-db 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,58 @@
1
+ import { MySqlTranslator } from '../src/MySQL/translator';
2
+ import { EntityDict, storageSchema } from './test-app-domain';
3
+
4
+ describe('test MysqlTranslator', function() {
5
+ this.timeout(100000);
6
+ let translator: MySqlTranslator<EntityDict>;
7
+ before(() => {
8
+ translator = new MySqlTranslator(storageSchema);
9
+ });
10
+
11
+ it('test create', () => {
12
+ const sql = translator.translateCreateEntity('token');
13
+ // console.log(sql);
14
+ });
15
+
16
+ it('test insert', () => {
17
+ const sql = translator.translateInsert('user', [{
18
+ id: 'xcxc',
19
+ name: 'xc',
20
+ nickname: 'xcxcxc',
21
+ }, {
22
+ id: 'gggg',
23
+ name: 'gg',
24
+ nickname: 'gggggg',
25
+ }]);
26
+ // console.log(sql);
27
+ });
28
+
29
+ it('test select', () => {
30
+ const sql = translator.translateSelect('token', {
31
+ data: {
32
+ id: 1,
33
+ $$createAt$$: 1,
34
+ userId: 1,
35
+ mobile: {
36
+ id: 1,
37
+ mobile: 1,
38
+ },
39
+ },
40
+ });
41
+ // console.log(sql);
42
+ });
43
+
44
+ it('test expression', () => {
45
+ const sql = translator.translateSelect('token', {
46
+ data: {
47
+ id: 1,
48
+ $expr: {
49
+ $dateDiff: [{
50
+ "#attr": '$$createAt$$',
51
+ }, new Date(), 'd'],
52
+ }
53
+ },
54
+ });
55
+ console.log(sql);
56
+ });
57
+
58
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "CommonJS",
4
+ "target": "es5",
5
+ "declaration": true,
6
+ "allowJs": false,
7
+ "allowSyntheticDefaultImports": true,
8
+ "esModuleInterop": true,
9
+ "experimentalDecorators": true,
10
+ "strict": true,
11
+ "skipLibCheck": true,
12
+ "lib": [
13
+ "ES2020",
14
+ "DOM"
15
+ ],
16
+ "outDir": "lib", /* Redirect output structure to the directory. */
17
+ "rootDir": "src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
18
+ "types": [
19
+ "node",
20
+ "mocha"
21
+ ],
22
+ "forceConsistentCasingInFileNames": true, /* Disallow inconsistently-cased references to the same file. */
23
+ "resolveJsonModule": true
24
+ },
25
+ "include": [
26
+ "src/**/*.ts"
27
+ ],
28
+ "exclude": [
29
+ "node_modules"
30
+ ]
31
+ }