@ronin/compiler 0.3.1 → 0.5.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.
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 { compileQueryInput } from '@ronin/compiler';
42
+ import {
43
+ compileQueries,
43
44
 
44
- const query = {
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
- const schemas = [
51
- {
52
- slug: 'account',
53
- },
54
- ];
68
+ #### Options
55
69
 
56
- const { writeStatements, readStatement } = compileQueryInput(query, schemas);
70
+ To fine-tune the behavior of the compiler, you can pass the following options:
57
71
 
58
- console.log(readStatement);
59
- // SELECT * FROM "accounts" ORDER BY "ronin.createdAt" DESC LIMIT 101
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