From 66c8587d3f620e798765e55ea79b89ebfd0adb08 Mon Sep 17 00:00:00 2001 From: Daniel Steigerwald Date: Thu, 21 Mar 2024 15:40:24 +0100 Subject: [PATCH] Add indexNoteStart --- components/DayNotes.tsx | 2 +- lib/Db.ts | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/DayNotes.tsx b/components/DayNotes.tsx index 862c174..01b8401 100644 --- a/components/DayNotes.tsx +++ b/components/DayNotes.tsx @@ -1,5 +1,6 @@ import { ExtractRow, NotNull, cast, useQuery } from "@evolu/react"; import { create, props } from "@stylexjs/stylex"; +import { ReadonlyArray, pipe } from "effect"; import { FC, memo, useMemo, useState } from "react"; import { Temporal } from "temporal-polyfill"; import { evolu } from "../lib/Db"; @@ -12,7 +13,6 @@ import { EditorOneLine } from "./EditorOneLine"; import { Formatted } from "./Formatted"; import { Link } from "./Link"; import { NoteDialog } from "./NoteDialog"; -import { ReadonlyArray, pipe } from "effect"; const notesByDay = (startOfDay: SqliteDateTime, endOfDay: SqliteDateTime) => evolu.createQuery((db) => diff --git a/lib/Db.ts b/lib/Db.ts index 3cfd4a4..e23fadf 100644 --- a/lib/Db.ts +++ b/lib/Db.ts @@ -1,8 +1,8 @@ import * as S from "@effect/schema/Schema"; import * as Evolu from "@evolu/react"; import { createEvolu, database, id, table } from "@evolu/react"; -import { SqliteDateTime } from "./temporal/castTemporal"; import { Content, ContentMax10k } from "./Lexical"; +import { SqliteDateTime } from "./temporal/castTemporal"; export const NoteId = id("Note"); export type NoteId = S.Schema.Type; @@ -34,5 +34,12 @@ const Database = database({ }); export type Database = S.Schema.Type; -export const evolu = createEvolu(Database); +const indexes = [ + Evolu.createIndex("indexNoteStart").on("note").column("start"), +]; + +export const evolu = createEvolu(Database, { + name: "Evolu.me", + indexes, +}); export const useEvolu = Evolu.useEvolu;