rado 0.1.5 → 0.1.7

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/dist/Cursor.d.ts CHANGED
@@ -6,8 +6,7 @@ import { Selection } from './Selection';
6
6
  import { Table } from './Table';
7
7
  import { Update as UpdateSet } from './Update';
8
8
  export declare class Cursor<T> {
9
- /** @internal */
10
- protected __cursorType: T;
9
+ [Selection.__cursorType](): T;
11
10
  constructor(query: Query<T>);
12
11
  query(): Query<T>;
13
12
  toJSON(): Query<T>;
@@ -72,6 +71,7 @@ export declare namespace Cursor {
72
71
  orderBy(...orderBy: Array<OrderBy>): SelectSingle<T>;
73
72
  groupBy(...groupBy: Array<Expr<any>>): SelectSingle<T>;
74
73
  where(...where: Array<EV<boolean>>): SelectSingle<T>;
74
+ all(): SelectMultiple<T>;
75
75
  toExpr(): Expr<T>;
76
76
  }
77
77
  }
package/dist/Cursor.js CHANGED
@@ -3,8 +3,12 @@ import { Expr, ExprData } from "./Expr.js";
3
3
  import { Functions } from "./Functions.js";
4
4
  import { Query } from "./Query.js";
5
5
  import { Schema } from "./Schema.js";
6
+ import { Selection } from "./Selection.js";
6
7
  import { Target } from "./Target.js";
7
8
  var Cursor = class {
9
+ [Selection.__cursorType]() {
10
+ throw "assert";
11
+ }
8
12
  constructor(query) {
9
13
  Object.defineProperty(this, "query", {
10
14
  enumerable: false,
@@ -201,6 +205,9 @@ var Cursor = class {
201
205
  where(...where) {
202
206
  return new SelectSingle(super.where(...where).query());
203
207
  }
208
+ all() {
209
+ return new SelectMultiple({ ...this.query(), singleResult: false });
210
+ }
204
211
  toExpr() {
205
212
  return new Expr(ExprData.Query(this.query()));
206
213
  }
package/dist/Driver.d.ts CHANGED
@@ -32,6 +32,7 @@ declare abstract class SyncDriver extends DriverBase {
32
32
  abstract schemaInstructions(tableName: string): SchemaInstructions | undefined;
33
33
  migrateSchema(...tables: Array<Table<any>>): unknown;
34
34
  executeQuery<T>(query: Query<T>): T;
35
+ all<T>(cursor: Cursor.SelectSingle<T>): Array<T>;
35
36
  all<T>(cursor: Cursor<T>): Array<T>;
36
37
  all<T>(strings: TemplateStringsArray, ...params: Array<any>): Array<T>;
37
38
  get<T>(cursor: Cursor.SelectMultiple<T>): T | null;
@@ -57,7 +58,8 @@ declare abstract class AsyncDriver extends DriverBase {
57
58
  abstract schemaInstructions(tableName: string): Promise<SchemaInstructions | undefined>;
58
59
  migrateSchema(...tables: Array<Table<any>>): Promise<unknown>;
59
60
  executeQuery<T>(query: Query<T>): Promise<T>;
60
- all<T>(cursor: Cursor<T>): Promise<Array<T>>;
61
+ all<T>(cursor: Cursor.SelectSingle<T>): Promise<Array<T>>;
62
+ all<T>(cursor: Cursor<T>): Promise<T>;
61
63
  all<T>(strings: TemplateStringsArray, ...params: Array<any>): Promise<Array<T>>;
62
64
  get<T>(cursor: Cursor.SelectMultiple<T>): Promise<T | null>;
63
65
  get<T>(cursor: Cursor<T>): Promise<T>;
package/dist/Driver.js CHANGED
@@ -33,6 +33,8 @@ var DriverBase = class extends Callable {
33
33
  }
34
34
  all(...args) {
35
35
  const [input, ...rest] = args;
36
+ if (input instanceof Cursor.SelectSingle)
37
+ return this.executeQuery(input.all().query());
36
38
  if (input instanceof Cursor)
37
39
  return this.executeQuery(input.query());
38
40
  return this.executeTemplate("rows", input, ...rest);
@@ -5,10 +5,12 @@ interface SelectionRecord extends Record<string, Selection> {
5
5
  }
6
6
  export type Selection = SelectionBase | SelectionRecord;
7
7
  export declare namespace Selection {
8
+ const __tableType: unique symbol;
9
+ const __cursorType: unique symbol;
8
10
  type Infer<T> = T extends {
9
- __tableType: infer K;
11
+ [__tableType](): infer K;
10
12
  } ? K : T extends {
11
- __cursortype: infer K;
13
+ [__cursorType](): infer K;
12
14
  } ? K : T extends Expr<infer K> ? K : T extends Record<string, Selection> ? {
13
15
  [K in keyof T]: Infer<T[K]>;
14
16
  } : T;
package/dist/Selection.js CHANGED
@@ -0,0 +1,7 @@
1
+ // src/Selection.ts
2
+ var Selection;
3
+ ((Selection2) => {
4
+ })(Selection || (Selection = {}));
5
+ export {
6
+ Selection
7
+ };
package/dist/Table.d.ts CHANGED
@@ -3,10 +3,10 @@ import { Cursor } from './Cursor';
3
3
  import { Expr } from './Expr';
4
4
  import { Fields } from './Fields';
5
5
  import { Schema } from './Schema';
6
+ import { Selection } from './Selection';
6
7
  import { Update } from './Update';
7
8
  export declare class Table<T> extends Cursor.SelectMultiple<T> {
8
- /** @internal */
9
- protected __tableType: T;
9
+ [Selection.__tableType](): T;
10
10
  constructor(schema: Schema);
11
11
  insertOne(record: Table.Insert<T>): Cursor.Batch<T>;
12
12
  insertAll(data: Array<Table.Insert<T>>): Cursor.InsertValues;
package/dist/Table.js CHANGED
@@ -2,8 +2,12 @@
2
2
  import { Cursor } from "./Cursor.js";
3
3
  import { Expr, ExprData } from "./Expr.js";
4
4
  import { Query } from "./Query.js";
5
+ import { Selection } from "./Selection.js";
5
6
  import { Target } from "./Target.js";
6
7
  var Table = class extends Cursor.SelectMultiple {
8
+ [Selection.__tableType]() {
9
+ throw "assert";
10
+ }
7
11
  constructor(schema) {
8
12
  super(
9
13
  Query.Select({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rado",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "exports": {