Skip to content

Commit

Permalink
feat: allow create group with extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
notrab committed Jan 19, 2024
1 parent 5d9cf4e commit f787fa4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ const closest = await turso.locations.closest();
```ts
const groups = await turso.groups.list();
const group = await turso.groups.get("default");
const group = await turso.groups.create("customgroup", "ams");
const group = await turso.groups.create("customgroup", "lhr");
const group = await turso.groups.create("customgroup", "ams", {
extensions: "all", // or ["uuid", "vector"]
});
const group = await turso.groups.delete("customgroup");
const group = await turso.groups.addLocation("default", "lhr");
const group = await turso.groups.removeLocation("default", "lhr");
Expand Down
21 changes: 19 additions & 2 deletions src/group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ export interface Group {
primary: keyof LocationKeys;
}

export type ExtensionType =
| "vector"
| "vss"
| "crypto"
| "fuzzy"
| "math"
| "stats"
| "text"
| "unicode"
| "uuid"
| "regexp";

export class GroupClient {
constructor(private config: TursoConfig) {}

Expand All @@ -31,7 +43,8 @@ export class GroupClient {

async create(
name: string,
location?: Array<keyof LocationKeys>
location: keyof LocationKeys,
options?: { extensions?: Array<ExtensionType> | "all" }
): Promise<Group> {
const response = await TursoClient.request<{ group: Group }>(
`organizations/${this.config.org}/groups`,
Expand All @@ -41,7 +54,11 @@ export class GroupClient {
headers: {
"content-type": "application/json",
},
body: JSON.stringify({ name, location }),
body: JSON.stringify({
name,
location,
...options,
}),
}
);

Expand Down

0 comments on commit f787fa4

Please sign in to comment.