Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/angular-vite-pwa/src/app/app.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { Injectable, inject, type OnDestroy, signal } from "@angular/core";
import { type InferRow, Mnemonic, type Query, type Row } from "@evolu/common";
import { EVOLU } from "./app.config";
import { formatTypeError } from "./error-formatter";
import type { TodoId } from "./schema";
import { createQuery, type TodoId } from "./schema";

@Injectable({ providedIn: "root" })
export class AppService implements OnDestroy {
private readonly evolu = inject(EVOLU);
private readonly unsubscribes: Array<() => void> = [];

private readonly todosQuery = this.evolu.createQuery((db) =>
private readonly todosQuery = createQuery((db) =>
db
.selectFrom("todo")
.select(["id", "title", "isCompleted"])
Expand Down
4 changes: 4 additions & 0 deletions examples/angular-vite-pwa/src/app/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
NonEmptyString100,
nullOr,
SqliteBoolean,
createQueryBuilder,
} from "@evolu/common";

// Define the typed IDs
Expand All @@ -19,3 +20,6 @@ const TodoSchema = {
export const Schema = {
todo: TodoSchema,
} satisfies EvoluSchema;

// Create a query builder (once per schema).
export const createQuery = createQueryBuilder(Schema);
5 changes: 4 additions & 1 deletion examples/react-electron/components/EvoluMinimalExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ export const EvoluMinimalExample: FC = () => {
);
};

// Create a query builder (once per schema).
const createQuery = Evolu.createQueryBuilder(Schema);

// Evolu uses Kysely for type-safe SQL (https://kysely.dev/).
const todosQuery = evolu.createQuery((db) =>
const todosQuery = createQuery((db) =>
db
// Type-safe SQL: try autocomplete for table and column names.
.selectFrom("todo")
Expand Down
5 changes: 4 additions & 1 deletion examples/react-expo/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@ const EvoluDemo = ({
}): React.ReactNode => {
const useEvolu = createUseEvolu(evolu);

// Create a query builder (once per schema).
const createQuery = Evolu.createQueryBuilder(Schema);

// Evolu uses Kysely for type-safe SQL (https://kysely.dev/).
const todosQuery = evolu.createQuery((db) =>
const todosQuery = createQuery((db) =>
db
// Type-safe SQL: try autocomplete for table and column names.
.selectFrom("todo")
Expand Down
5 changes: 4 additions & 1 deletion examples/react-nextjs/components/EvoluMinimalExample.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ export const EvoluMinimalExample: FC = () => {
);
};

// Create a query builder (once per schema).
const createQuery = Evolu.createQueryBuilder(Schema);

// Evolu uses Kysely for type-safe SQL (https://kysely.dev/).
const todosQuery = evolu.createQuery((db) =>
const todosQuery = createQuery((db) =>
db
// Type-safe SQL: try autocomplete for table and column names.
.selectFrom("todo")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ export const EvoluMinimalExample: FC = () => {
);
};

// Create a query builder (once per schema).
const createQuery = Evolu.createQueryBuilder(Schema);

// Evolu uses Kysely for type-safe SQL (https://kysely.dev/).
const todosQuery = evolu.createQuery((db) =>
const todosQuery = createQuery((db) =>
db
// Type-safe SQL: try autocomplete for table and column names.
.selectFrom("todo")
Expand Down
5 changes: 4 additions & 1 deletion examples/svelte-vite-pwa/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@
console.error(error);
});

// Create a query builder (once per schema).
const createQuery = Evolu.createQueryBuilder(Schema);

// Evolu uses Kysely for type-safe SQL (https://kysely.dev/).
const todosQuery = evolu.createQuery((db) =>
const todosQuery = createQuery((db) =>
db
// Type-safe SQL: try autocomplete for table and column names.
.selectFrom("todo")
Expand Down
8 changes: 6 additions & 2 deletions examples/vue-vite-pwa/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
sqliteTrue,
createEvolu,
createFormatTypeError,
createQueryBuilder,
id,
kysely,
maxLength,
Expand Down Expand Up @@ -60,7 +61,10 @@ const evolu = createEvolu(evoluWebDeps)(DatabaseSchema, {

provideEvolu(evolu);

const todosWithCategories = evolu.createQuery((db) =>
// Create a query builder (once per schema).
const createQuery = createQueryBuilder(DatabaseSchema);

const todosWithCategories = createQuery((db) =>
db
.selectFrom("todo")
.select(["id", "title", "isCompleted", "categoryId", "priority"])
Expand All @@ -70,7 +74,7 @@ const todosWithCategories = evolu.createQuery((db) =>
.orderBy("createdAt"),
);

const todoCategories = evolu.createQuery((db) =>
const todoCategories = createQuery((db) =>
db
.selectFrom("todoCategory")
.select(["id", "name"])
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"lint": "biome check",
"lint-monorepo": "bunx sherif@latest",
"format": "biome format --write .",
"verify": "bun run format && bun run build && bun run test && bun run test:coverage && bun run lint && bun run lint-monorepo && bunx vitest run scripts/typedoc-plugin-evolu.test.mts",
"verify": "bun run format && bun run build && bun run test && bun run test:coverage && bun run lint && bun run lint-monorepo && bun run build:docs && bunx vitest run scripts/typedoc-plugin-evolu.test.mts",
"clean": "turbo clean && rimraf node_modules bun.lock .turbo out",
"version": "changeset version",
"release": "bun run build && changeset publish",
Expand Down