cl-orm 0.1.0 → 0.1.2

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.
Files changed (103) hide show
  1. package/lib/drivers/_utils.d.ts +4 -0
  2. package/lib/drivers/_utils.js +23 -0
  3. package/lib/drivers/d1.d.ts +2 -0
  4. package/lib/drivers/d1.js +48 -0
  5. package/lib/drivers/do.d.ts +2 -0
  6. package/lib/drivers/do.js +45 -0
  7. package/{src/index.ts → lib/index.d.ts} +1 -10
  8. package/lib/index.js +9 -0
  9. package/lib/queries/_utils.d.ts +1 -0
  10. package/lib/queries/_utils.js +13 -0
  11. package/lib/queries/delete.d.ts +5 -0
  12. package/lib/queries/delete.js +22 -0
  13. package/lib/queries/insert.d.ts +5 -0
  14. package/lib/queries/insert.js +19 -0
  15. package/lib/queries/select.d.ts +5 -0
  16. package/lib/queries/select.js +55 -0
  17. package/lib/queries/update.d.ts +5 -0
  18. package/lib/queries/update.js +25 -0
  19. package/lib/queries/where/operators.d.ts +23 -0
  20. package/lib/queries/where/operators.js +60 -0
  21. package/lib/queries/where/where.d.ts +5 -0
  22. package/lib/queries/where/where.js +34 -0
  23. package/lib/types.d.ts +64 -0
  24. package/lib/types.js +2 -0
  25. package/package.json +32 -2
  26. package/.editorconfig +0 -12
  27. package/.gitattributes +0 -1
  28. package/.prettierignore +0 -3
  29. package/.prettierrc +0 -34
  30. package/.vscode/settings.json +0 -14
  31. package/mcr.config.ts +0 -12
  32. package/src/drivers/_utils.ts +0 -31
  33. package/src/drivers/d1.ts +0 -70
  34. package/src/drivers/do.ts +0 -81
  35. package/src/queries/_utils.ts +0 -10
  36. package/src/queries/delete.ts +0 -26
  37. package/src/queries/insert.ts +0 -22
  38. package/src/queries/select.ts +0 -64
  39. package/src/queries/update.ts +0 -28
  40. package/src/queries/where/operators.ts +0 -96
  41. package/src/queries/where/where.ts +0 -50
  42. package/src/types.ts +0 -76
  43. package/test/__fixtures__/d1/worker.ts +0 -70
  44. package/test/__fixtures__/d1/wrangler.jsonc +0 -13
  45. package/test/__fixtures__/do/worker.ts +0 -106
  46. package/test/__fixtures__/do/wrangler.jsonc +0 -20
  47. package/test/e2e/d1.test.ts +0 -113
  48. package/test/e2e/do.test.ts +0 -116
  49. package/test/unit/buildDelete.test.ts +0 -36
  50. package/test/unit/buildInsert.test.ts +0 -36
  51. package/test/unit/buildSelect.test.ts +0 -137
  52. package/test/unit/buildUpdate.test.ts +0 -34
  53. package/test/unit/buildWhere.test.ts +0 -249
  54. package/test/unit/operators.test.ts +0 -98
  55. package/test/unit/prepare.test.ts +0 -22
  56. package/test/unit/quoteIdentifier.test.ts +0 -12
  57. package/test/unit/returnsRows.test.ts +0 -41
  58. package/test/unit/setMeta.test.ts +0 -31
  59. package/tsconfig.build.json +0 -4
  60. package/tsconfig.json +0 -34
  61. package/website/.prettierignore +0 -4
  62. package/website/.prettierrc +0 -34
  63. package/website/README.md +0 -3
  64. package/website/docs/documentation/connection.mdx +0 -123
  65. package/website/docs/documentation/queries/_category_.json +0 -7
  66. package/website/docs/documentation/queries/delete.mdx +0 -51
  67. package/website/docs/documentation/queries/insert.mdx +0 -63
  68. package/website/docs/documentation/queries/operators/_category_.json +0 -7
  69. package/website/docs/documentation/queries/operators/between.mdx +0 -17
  70. package/website/docs/documentation/queries/operators/eq.mdx +0 -22
  71. package/website/docs/documentation/queries/operators/gt.mdx +0 -22
  72. package/website/docs/documentation/queries/operators/gte.mdx +0 -22
  73. package/website/docs/documentation/queries/operators/in.mdx +0 -28
  74. package/website/docs/documentation/queries/operators/is-not-null.mdx +0 -22
  75. package/website/docs/documentation/queries/operators/is-null.mdx +0 -22
  76. package/website/docs/documentation/queries/operators/like.mdx +0 -27
  77. package/website/docs/documentation/queries/operators/lt.mdx +0 -22
  78. package/website/docs/documentation/queries/operators/lte.mdx +0 -22
  79. package/website/docs/documentation/queries/operators/ne.mdx +0 -22
  80. package/website/docs/documentation/queries/operators/not-between.mdx +0 -17
  81. package/website/docs/documentation/queries/operators/not-like.mdx +0 -27
  82. package/website/docs/documentation/queries/operators/notIn.mdx +0 -28
  83. package/website/docs/documentation/queries/select.mdx +0 -294
  84. package/website/docs/documentation/queries/update.mdx +0 -61
  85. package/website/docs/documentation/queries/where.mdx +0 -176
  86. package/website/docs/index.mdx +0 -228
  87. package/website/docusaurus.config.ts +0 -82
  88. package/website/package-lock.json +0 -21348
  89. package/website/package.json +0 -59
  90. package/website/plugins/locale.ts +0 -16
  91. package/website/sidebars.ts +0 -18
  92. package/website/src/components/FAQ.tsx +0 -35
  93. package/website/src/components/Loading.tsx +0 -4
  94. package/website/src/components/PageTitle.tsx +0 -29
  95. package/website/src/css/_faq.scss +0 -39
  96. package/website/src/css/_loading.scss +0 -43
  97. package/website/src/css/_mixins.scss +0 -19
  98. package/website/src/css/custom.scss +0 -149
  99. package/website/src/pages/index.tsx +0 -17
  100. package/website/static/.nojekyll +0 -0
  101. package/website/static/img/favicon.svg +0 -1
  102. package/website/test/unit/check-extensions.test.ts +0 -48
  103. package/website/tsconfig.json +0 -14
@@ -1,51 +0,0 @@
1
- ---
2
- sidebar_position: 4
3
- ---
4
-
5
- # DELETE
6
-
7
- > For **WHERE** examples, please see the **WHERE** section.
8
-
9
- ## Delete all rows
10
-
11
- ```ts
12
- // highlight-start
13
- import { useD1 } from 'cl-orm';
14
-
15
- const db = useD1(env.DB);
16
- // highlight-end
17
-
18
- await db.delete({
19
- table: 'temp',
20
- });
21
- ```
22
-
23
- > SQL Query
24
-
25
- ```sql
26
- DELETE FROM temp
27
- ```
28
-
29
- <hr />
30
-
31
- ## Limit the rows to be deleted
32
-
33
- ```ts
34
- // highlight-start
35
- import { useD1 } from 'cl-orm';
36
-
37
- const db = useD1(env.DB);
38
- // highlight-end
39
-
40
- await db.delete({
41
- table: 'test',
42
- limit: 1,
43
- });
44
- ```
45
-
46
- > SQL Query
47
-
48
- ```sql
49
- DELETE FROM test LIMIT ?
50
- -- params: [1]
51
- ```
@@ -1,63 +0,0 @@
1
- ---
2
- sidebar_position: 0
3
- ---
4
-
5
- # INSERT
6
-
7
- ## Single insertion
8
-
9
- ```ts
10
- // highlight-start
11
- import { useD1 } from 'cl-orm';
12
-
13
- const db = useD1(env.DB);
14
- // highlight-end
15
-
16
- await db.insert({
17
- table: 'test',
18
- values: {
19
- column1: 'foo',
20
- column2: 1,
21
- },
22
- });
23
- ```
24
-
25
- > SQL Query
26
-
27
- ```sql
28
- INSERT INTO test (column1, column2) VALUES (?, ?)
29
- -- params: ['foo', 1]
30
- ```
31
-
32
- <hr />
33
-
34
- ## Multiple insertions
35
-
36
- ```ts
37
- // highlight-start
38
- import { useD1 } from 'cl-orm';
39
-
40
- const db = useD1(env.DB);
41
- // highlight-end
42
-
43
- await db.insert({
44
- table: 'test',
45
- values: [
46
- {
47
- column1: 'foo',
48
- column2: 1,
49
- },
50
- {
51
- column1: 'bar',
52
- column2: 2,
53
- },
54
- ],
55
- });
56
- ```
57
-
58
- > SQL Query
59
-
60
- ```sql
61
- INSERT INTO test (column1, column2) VALUES (?, ?), (?, ?)
62
- -- params: ['foo', 1, 'bar', 2]
63
- ```
@@ -1,7 +0,0 @@
1
- {
2
- "label": "Operators",
3
- "link": {
4
- "type": "generated-index"
5
- },
6
- "position": 6
7
- }
@@ -1,17 +0,0 @@
1
- ---
2
- sidebar_position: 13
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # between
7
-
8
- > between(column: string, params: [Param, Param])
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`createdAt` BETWEEN ? AND ?', params: ['2023-01-01', '2024-01-01'] }
15
- */
16
- OP.between('createdAt', ['2023-01-01', '2024-01-01']);
17
- ```
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 1
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # eq (equal)
7
-
8
- > eq(column: string, param: Param)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`id` = ?', params: [16] }
15
- */
16
- OP.eq('id', 16);
17
-
18
- /**
19
- * { condition: '`name` = ?', params: ['John'] }
20
- */
21
- OP.eq('name', 'John');
22
- ```
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 5
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # gt (greaterThan)
7
-
8
- > gt(column: string, param: Param)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`id` > ?', params: [16] }
15
- */
16
- OP.gt('id', 16);
17
-
18
- /**
19
- * { condition: '`createdAt` > ?', params: ['2024-01-01'] }
20
- */
21
- OP.gt('createdAt', '2024-01-01');
22
- ```
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 7
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # gte (greaterThanOrEqual)
7
-
8
- > gte(column: string, param: Param)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`id` >= ?', params: [16] }
15
- */
16
- OP.gte('id', 16);
17
-
18
- /**
19
- * { condition: '`createdAt` >= ?', params: ['2024-01-01'] }
20
- */
21
- OP.gte('createdAt', '2024-01-01');
22
- ```
@@ -1,28 +0,0 @@
1
- ---
2
- sidebar_position: 11
3
- tags: [OP, Operators, Sub Query, Sub Queries]
4
- ---
5
-
6
- # in
7
-
8
- > in(column: string, params: Param[])
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: 'id IN (?, ?, ?)', params: [16, 20, 50] }
15
- */
16
- OP.in('id', [16, 20, 50]);
17
- ```
18
-
19
- > in(column: string, subquery: string, params: Param[])
20
-
21
- ```ts
22
- import { OP, Param } from 'cl-orm';
23
-
24
- /**
25
- * { condition: 'userId IN (SELECT id FROM users WHERE status IN (?, ?))', params: [0, 2] }
26
- */
27
- OP.in('userId', 'SELECT id FROM users WHERE status IN (?, ?)', [0, 2]);
28
- ```
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 10
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # isNotNull
7
-
8
- > isNotNull(column: string)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`preferences` IS NOT NULL', params: [] }
15
- */
16
- OP.isNotNull('preferences');
17
-
18
- /**
19
- * { condition: '`updatedAt` IS NOT NULL', params: [] }
20
- */
21
- OP.isNotNull('updatedAt');
22
- ```
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 9
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # isNull
7
-
8
- > isNull(column: string)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`preferences` IS NULL', params: [] }
15
- */
16
- OP.isNull('preferences');
17
-
18
- /**
19
- * { condition: '`updatedAt` IS NULL', params: [] }
20
- */
21
- OP.isNull('updatedAt');
22
- ```
@@ -1,27 +0,0 @@
1
- ---
2
- sidebar_position: 3
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # like
7
-
8
- > like(column: string, param: Param)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`email` LIKE ?', params: ['%gmail.com'] }
15
- */
16
- OP.like('email', '%gmail.com');
17
-
18
- /**
19
- * { condition: '`email` LIKE ?', params: ['john@%'] }
20
- */
21
- OP.like('email', 'john@%');
22
-
23
- /**
24
- * { condition: '`email` LIKE ?', params: ['%gmail%'] }
25
- */
26
- OP.like('email', '%gmail%');
27
- ```
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 6
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # lt (lessThan)
7
-
8
- > lt(column: string, param: Param)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`id` < ?', params: [16] }
15
- */
16
- OP.lt('id', 16);
17
-
18
- /**
19
- * { condition: '`createdAt` < ?', params: ['2024-01-01'] }
20
- */
21
- OP.lt('createdAt', '2024-01-01');
22
- ```
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 8
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # lte (lessThanOrEqual)
7
-
8
- > lte(column: string, param: Param)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`id` <= ?', params: [16] }
15
- */
16
- OP.lte('id', 16);
17
-
18
- /**
19
- * { condition: '`createdAt` <= ?', params: ['2024-01-01'] }
20
- */
21
- OP.lte('createdAt', '2024-01-01');
22
- ```
@@ -1,22 +0,0 @@
1
- ---
2
- sidebar_position: 2
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # ne (notEqual)
7
-
8
- > ne(column: string, param: Param)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`id` != ?', params: [16] }
15
- */
16
- OP.ne('id', 16);
17
-
18
- /**
19
- * { condition: '`name` != ?', params: ['John'] }
20
- */
21
- OP.ne('name', 'John');
22
- ```
@@ -1,17 +0,0 @@
1
- ---
2
- sidebar_position: 14
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # notBetween
7
-
8
- > notBetween(column: string, params: [Param, Param])
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`createdAt` NOT BETWEEN ? AND ?', params: ['2023-01-01', '2024-01-01'] }
15
- */
16
- OP.notBetween('createdAt', ['2023-01-01', '2024-01-01']);
17
- ```
@@ -1,27 +0,0 @@
1
- ---
2
- sidebar_position: 4
3
- tags: [OP, Operators]
4
- ---
5
-
6
- # notLike
7
-
8
- > notLike(column: string, param: Param)
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: '`email` NOT LIKE ?', params: ['%gmail.com'] }
15
- */
16
- OP.notLike('email', '%gmail.com');
17
-
18
- /**
19
- * { condition: '`email` NOT LIKE ?', params: ['john@%'] }
20
- */
21
- OP.notLike('email', 'john@%');
22
-
23
- /**
24
- * { condition: '`email` NOT LIKE ?', params: ['%gmail%'] }
25
- */
26
- OP.notLike('email', '%gmail%');
27
- ```
@@ -1,28 +0,0 @@
1
- ---
2
- sidebar_position: 12
3
- tags: [OP, Operators, Sub Query, Sub Queries]
4
- ---
5
-
6
- # notIn
7
-
8
- > notIn(column: string, params: Param[])
9
-
10
- ```ts
11
- import { OP, Param } from 'cl-orm';
12
-
13
- /**
14
- * { condition: 'id NOT IN (?, ?, ?)', params: [16, 20, 50] }
15
- */
16
- OP.notIn('id', [16, 20, 50]);
17
- ```
18
-
19
- > notIn(column: string, subquery: string, params: Param[])
20
-
21
- ```ts
22
- import { OP, Param } from 'cl-orm';
23
-
24
- /**
25
- * { condition: 'userId NOT IN (SELECT id FROM users WHERE status IN (?, ?))', params: [0, 2] }
26
- */
27
- OP.notIn('userId', 'SELECT id FROM users WHERE status IN (?, ?)', [0, 2]);
28
- ```