@ronin/compiler 0.3.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +34 -13
- package/dist/index.d.ts +17 -14233
- package/dist/index.js +151 -90
- package/package.json +1 -1
package/README.md
CHANGED
@@ -39,26 +39,47 @@ You will just need to make sure that, once you [create a pull request](https://d
|
|
39
39
|
The programmatic API of the RONIN compiler looks like this:
|
40
40
|
|
41
41
|
```typescript
|
42
|
-
import {
|
42
|
+
import {
|
43
|
+
compileQueries,
|
43
44
|
|
44
|
-
|
45
|
+
type Query,
|
46
|
+
type Schema,
|
47
|
+
type Statement
|
48
|
+
} from '@ronin/compiler';
|
49
|
+
|
50
|
+
const queries: Array<Query> = [{
|
45
51
|
get: {
|
46
|
-
accounts: null
|
47
|
-
}
|
48
|
-
};
|
52
|
+
accounts: null
|
53
|
+
}
|
54
|
+
}];
|
55
|
+
|
56
|
+
const schemas: Array<Schema> = [{
|
57
|
+
slug: 'account'
|
58
|
+
}];
|
59
|
+
|
60
|
+
const statements: Array<Statements> = compileQueries(queries, schemas);
|
61
|
+
// [{
|
62
|
+
// statement: 'SELECT * FROM "accounts" ORDER BY "ronin.createdAt" DESC LIMIT 101',
|
63
|
+
// params: [],
|
64
|
+
// returning: true,
|
65
|
+
// }]
|
66
|
+
```
|
49
67
|
|
50
|
-
|
51
|
-
{
|
52
|
-
slug: 'account',
|
53
|
-
},
|
54
|
-
];
|
68
|
+
#### Options
|
55
69
|
|
56
|
-
|
70
|
+
To fine-tune the behavior of the compiler, you can pass the following options:
|
57
71
|
|
58
|
-
|
59
|
-
|
72
|
+
```typescript
|
73
|
+
compileQueries(queries, schemas, {
|
74
|
+
// Instead of returning an array of values for every statement (which allows for
|
75
|
+
// preventing SQL injections), all values are inlined directly into the SQL strings.
|
76
|
+
// This option should only be used if the generated SQL will be manually verified.
|
77
|
+
inlineValues: true
|
78
|
+
});
|
60
79
|
```
|
61
80
|
|
81
|
+
#### Transpilation
|
82
|
+
|
62
83
|
In order to be compatible with a wide range of projects, the source code of the `compiler` repo needs to be compiled (transpiled) whenever you make changes to it. To automate this, you can keep this command running in your terminal:
|
63
84
|
|
64
85
|
```bash
|