Repository navigation
Upgrade notes
-
A query is no longer a promise.
Queryhas nothen(), andQueryExecutionno longer extendsPromiseLike.await querygives back the query object and sends nothing to the provider. Run a query withrun(), or read it withcursor()orfor await. A query inPromise.all([...]), or returned from anasyncfunction, is no longer run either. TypeScript rejects a query passed where aPromiseLikeis expected, and thetypescript/await-thenablelint rule reportsawaiton a query and a query passed toPromise.all,Promise.raceor another promise aggregator. The conformance suite indist/testsruns every query withrun(). A database module implements nothing new.// Before const adults = await users.filter((u) => u.key("age").ge(18)); // After const adults = await users.filter((u) => u.key("age").ge(18)).run();
-
cast()returns a new object.Datum#cast,Stream#castandValueProxy#castreturn a new object with the same stages, built by the newStagedObjectconstructor formnew X(undefined, previous), which records no stage.cast()on aTable, aSelectionor aSingleSelectionreturns a plainStreamorDatum, the class its type already declared. Code that compared the result with its receiver, or relied on it keeping the subclass methods at runtime, such as a table'sinsertorgetAll, keeps the receiver instead.// Before: the same object, still a Table at runtime table.cast<Row>() === table; // true // After: a new Stream with the same stages table.cast<Row>() === table; // false table.cast<Row>().build(); // equal to table.build()
-
Schema.get()takes no type arguments. The registry keeps none, soSchema.get(id)returnsSchema<any, unknown> | undefined: tables holdanydocuments, and the definition is typedunknown. A typed lookup such asSchema.get<{ users: User }>(id)fails to compile (TS2558). Query typed tables through the schema object the constructor returned. On the runtime entry,Schema.list().get(id)returns the schema with its definition typedSchemaDefinition.// Before const schema = Schema.get<{ users: User }>("myapp")!; // After: export the schema you define, and import it export const schema = new Schema<{ users: User }>("myapp", definition);
-
The build-only
Query<T>keeps its result type. Loaded from@antelopejs/interface-database/staged-queryalone,Query<T>now usesT, soExtractTypereads the result type of aDatumor aStreama mapper returns, and aQuery<string>is no longer assignable to aQuery<number>. Code that relied on that assignment fails to compile.// Before, build-only entry: compiled, typed unknown const q: Query<number> = schema.createInstance(); // Query<string> // After: TS2322
-
StagedObject#callfuncchecks its argument classes. The protected method takes one or twoStagedConstructors, and each must build the parameter typefuncdeclares. A subclass that passedValueProxy<unknown>for a parameter typedValueProxy<T>passesValueProxy<T>.// Before this.callfunc(mapper, Stream<T>, ValueProxy<unknown>); // After this.callfunc( mapper, Stream<T>, ValueProxy<K extends keyof T ? T[K] : unknown>, );
🚀 Enhancements
- staged-query:
⚠️ Drop casts, thenable queries and caller-typed schema lookups (#91)
💅 Refactors
- tests: Drop the no-unused-expressions suppression (#88)
📖 Documentation
- readme: List the mysql and postgres backends among the implementations (#89)
✅ Tests
- atomic: Move off-contract refusal checks into an untyped spec (#90)
🤖 CI
- release: Accept an exact release-version on dispatch (#92)
⚠️ Breaking Changes
- staged-query:
⚠️ Drop casts, thenable queries and caller-typed schema lookups (#91)
❤️ Contributors
- Antony Rizzitelli (@Upd4ting)