Skip to content
Open
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
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Formatted with oxfmt when the repository moved off Biome.
ed60ad19c4be5957b838e8551a40f3886cfe5515
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@ jobs:
- run: pnpm add --global @antelopejs/core
- run: pnpm prepack
- run: pnpm lint
- run: pnpm format:check
- run: pnpm knip
- run: pnpm test
8 changes: 4 additions & 4 deletions .github/workflows/stale.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: 'Close stale issues'
name: "Close stale issues"

on:
schedule:
- cron: '30 * * * *'
- cron: "30 * * * *"
workflow_dispatch:

permissions:
Expand All @@ -17,8 +17,8 @@ jobs:
- uses: actions/stale@v9
with:
exempt-issue-labels: pending
stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.'
close-issue-message: 'This issue was closed because it has been stalled for 30 days with no activity.'
stale-issue-message: "This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days."
close-issue-message: "This issue was closed because it has been stalled for 30 days with no activity."
days-before-stale: 60
days-before-close: 30
operations-per-run: 200
Expand Down
18 changes: 9 additions & 9 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
| --------------------- | --------------------------------------------------------------------------------------- |
| English only | All code must be in English: variable names, function names, comments |
| PNPM only | Always use pnpm, never npm or yarn |
| NO COMMENTS | Code must be self-documenting through clear naming. TSDoc is allowed for public APIs |
| NO COMMENTS | Code must be self-documenting through clear naming. TSDoc is allowed for public APIs |
| NO switch/case | Use objects, maps, or arrays instead |
| NO inline types | Define proper interfaces/types, never use anonymous types like `{a: string, b: number}` |
| Functions ≤ 40 lines | Split into subfunctions if longer |
Expand All @@ -35,23 +35,23 @@ Never use `switch/case` or `if param === 'XXX'` chains. Instead:
// BAD
function getStatus(code: string) {
switch (code) {
case 'A':
return 'Active';
case 'I':
return 'Inactive';
case "A":
return "Active";
case "I":
return "Inactive";
default:
return 'Unknown';
return "Unknown";
}
}

// GOOD
const STATUS_MAP: Record<string, string> = {
A: 'Active',
I: 'Inactive',
A: "Active",
I: "Inactive",
};

function getStatus(code: string) {
return STATUS_MAP[code] ?? 'Unknown';
return STATUS_MAP[code] ?? "Unknown";
}
```

Expand Down
3 changes: 0 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Changelog


## v0.1.4

[compare changes](https://github.com/AntelopeJS/interface-database/compare/v0.1.3...v0.1.4)
Expand Down Expand Up @@ -111,7 +110,6 @@

## v0.0.2


### 🚀 Enhancements

- Initial interface-database package ([f73d27c](https://github.com/AntelopeJS/interface-database/commit/f73d27c))
Expand All @@ -136,4 +134,3 @@

- Antony Rizzitelli <upd4ting@gmail.com>
- Glastis ([@Glastis](http://github.com/Glastis))

56 changes: 0 additions & 56 deletions biome.json

This file was deleted.

14 changes: 10 additions & 4 deletions docs/1.query_types/2.table.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ The `Table<T>` class represents a database table and provides methods for insert

```typescript
class Table<T> extends Selection<T> {
insert(obj: DeepPartial<T> | DeepPartial<T>[], options?: InsertOptions): Query<string[]>;
insert(
obj: DeepPartial<T> | DeepPartial<T>[],
options?: InsertOptions,
): Query<string[]>;
get(key: string): SingleSelection<T>;
getAll(keys: string | number | boolean | (string | number | boolean)[], index?: string): Selection<T>;
getAll(
keys: string | number | boolean | (string | number | boolean)[],
index?: string,
): Selection<T>;
between<TK extends keyof T>(index: TK, low: T[TK], high: T[TK]): Selection<T>;
}
```
Expand Down Expand Up @@ -58,8 +64,8 @@ const upsertIds = await users.insert(

### `InsertOptions`

| Option | Type | Description |
| ---------- | ------------------------ | --------------------------------------------------- |
| Option | Type | Description |
| ---------- | ----------------------- | ------------------------------------------------- |
| `conflict` | `"update" \| "replace"` | Behavior when a document with the same ID exists. |

## Retrieve Documents
Expand Down
32 changes: 15 additions & 17 deletions docs/1.query_types/3.selection.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ const users = schema.instance().table("users");
const admins = users.getAll("admin", "role");

// Selection from between
const recentUsers = users.between("createdAt", new Date("2024-01-01"), new Date());
const recentUsers = users.between(
"createdAt",
new Date("2024-01-01"),
new Date(),
);
```

## Update Documents
Expand All @@ -43,26 +47,22 @@ const count = await users
console.log(`Activated ${count} users`);

// Update with a function for computed values
await users
.getAll("active", "status")
.update((user) => ({
loginCount: user.key("loginCount").add(1),
}));
await users.getAll("active", "status").update((user) => ({
loginCount: user.key("loginCount").add(1),
}));
```

## Replace Documents

The `replace` method substitutes entire documents with the provided data. Unlike `update`, all fields not present in the replacement are removed.

```typescript
const count = await users
.getAll("user-123")
.replace({
_id: "user-123",
name: "New Name",
email: "new@example.com",
role: "user",
});
const count = await users.getAll("user-123").replace({
_id: "user-123",
name: "New Name",
email: "new@example.com",
role: "user",
});

console.log(`Replaced ${count} documents`);
```
Expand All @@ -72,9 +72,7 @@ console.log(`Replaced ${count} documents`);
The `delete` method removes all documents in the selection and returns the number of deleted documents.

```typescript
const count = await users
.getAll("inactive", "status")
.delete();
const count = await users.getAll("inactive", "status").delete();

console.log(`Deleted ${count} inactive users`);
```
Expand Down
7 changes: 2 additions & 5 deletions docs/1.query_types/5.stream.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ Select documents matching a predicate. The callback returns a boolean expression

```typescript
const active = await users.filter((user) =>
user.key("status").eq("active")
.and(user.key("age").ge(18)),
user.key("status").eq("active").and(user.key("age").ge(18)),
);
```

Expand All @@ -109,9 +108,7 @@ Concatenate two streams without deduplication.
```typescript
const allPremium = await users
.filter((u) => u.key("plan").eq("premium"))
.union(
users.filter((u) => u.key("plan").eq("enterprise")),
);
.union(users.filter((u) => u.key("plan").eq("enterprise")));
```

## Join Data
Expand Down
2 changes: 1 addition & 1 deletion docs/1.query_types/6.feed.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Changes<T> {

| Property | Description |
| ------------ | ------------------------------------------------------------------ |
| `changeType` | The type of change: `"added"`, `"removed"`, or `"modified"`. |
| `changeType` | The type of change: `"added"`, `"removed"`, or `"modified"`. |
| `oldValue` | The document value before the change. Undefined for new documents. |
| `newValue` | The document value after the change. Undefined for deletions. |

Expand Down
Loading
Loading