@ronin/compiler 0.4.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
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 { compileQuery } from '@ronin/compiler';
42
+ import {
43
+ compileQueries,
43
44
 
44
- const query = {
45
- get: {
46
- accounts: null,
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 { writeStatements, readStatement } = compileQuery(query, schemas);
57
-
58
- console.log(readStatement);
59
- // SELECT * FROM "accounts" ORDER BY "ronin.createdAt" DESC LIMIT 101
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"',
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
- compileQuery(query, schemas, {
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.