@ronin/compiler 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +23 -17
- package/dist/index.d.ts +9 -14228
- package/dist/index.js +93 -75
- package/package.json +1 -1
package/README.md
CHANGED
@@ -39,24 +39,30 @@ 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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
};
|
49
|
-
|
50
|
-
const schemas = [
|
51
|
-
{
|
52
|
-
slug: 'account',
|
53
|
-
},
|
54
|
-
];
|
45
|
+
type Query,
|
46
|
+
type Schema,
|
47
|
+
type Statement
|
48
|
+
} from '@ronin/compiler';
|
55
49
|
|
56
|
-
const
|
57
|
-
|
58
|
-
|
59
|
-
|
50
|
+
const queries: Array<Query> = [{
|
51
|
+
get: {
|
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
|
+
// }]
|
60
66
|
```
|
61
67
|
|
62
68
|
#### Options
|
@@ -64,7 +70,7 @@ console.log(readStatement);
|
|
64
70
|
To fine-tune the behavior of the compiler, you can pass the following options:
|
65
71
|
|
66
72
|
```typescript
|
67
|
-
|
73
|
+
compileQueries(queries, schemas, {
|
68
74
|
// Instead of returning an array of values for every statement (which allows for
|
69
75
|
// preventing SQL injections), all values are inlined directly into the SQL strings.
|
70
76
|
// This option should only be used if the generated SQL will be manually verified.
|