feat: release 3.0.2

This commit is contained in:
2026-01-07 02:34:18 +01:00
parent 72355de920
commit 53b43f6253
7 changed files with 241 additions and 285 deletions

View File

@@ -29,7 +29,17 @@ describe("Collection", { sanitizeOps: false, sanitizeResources: false }, () => {
name: string;
storage: MemoryStorage;
schema: UserSchema;
indexes: [{ field: "id"; kind: "primary" }];
indexes: [
{ field: "id"; kind: "primary" },
{
field: "emails";
kind: "unique";
},
{
field: "name";
kind: "shared";
},
];
}>;
beforeEach(() => {
@@ -40,25 +50,29 @@ describe("Collection", { sanitizeOps: false, sanitizeResources: false }, () => {
field: "id",
kind: "primary",
},
{
field: "emails",
kind: "unique",
},
{
field: "name",
kind: "shared",
},
]),
schema: {
id: z.string(),
name: z.string().optional(),
fullName: z.string().optional(),
emails: z.array(z.email()),
friends: z.array(
z.object({
id: z.string(),
type: z.union([z.literal("family"), z.literal("close")]),
}),
),
age: z.number(),
},
schema,
indexes: [
{
field: "id",
kind: "primary",
},
{
field: "emails",
kind: "unique",
},
{
field: "name",
kind: "shared",
},
],
});
});
@@ -239,6 +253,18 @@ describe("Collection", { sanitizeOps: false, sanitizeResources: false }, () => {
expect(docs.every((d) => d.age >= 30)).toBe(true);
});
it("should find documents by indexed condition", async () => {
const docs = await collection.findMany({ name: "Bob" });
expect(docs).toHaveLength(1);
expect(docs[0].name).toBe("Bob");
});
it("should find documents by nested indexed condition", async () => {
const docs = await collection.findMany({ emails: { $in: ["charlie@test.com"] } });
expect(docs).toHaveLength(1);
expect(docs[0].emails[0]).toBe("charlie@test.com");
});
it("should support limit option", async () => {
const docs = await collection.findMany({}, { limit: 2 });
expect(docs).toHaveLength(2);