Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Commit

Permalink
add view collection support
Browse files Browse the repository at this point in the history
  • Loading branch information
Satoshi committed Mar 9, 2024
1 parent dbcba08 commit 84258cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/pretty-seahorses-raise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"pb-option-builder": patch
---

support view collections
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ type Schema = {

type Relations = {
// column names as keys
post: Post
user: User
post: Post // if you have view collections, use union like "post: Post | ViewCollectionName"

// if the relation is one-to-many or many-to-many, use Array<>
tags: Array<Tag>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pb-option-builder",
"version": "0.1.0",
"version": "0.1.1",
"description": "Option builder for the official PocketBase SDK that also helps with typing the response",
"author": "satohshi",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Related<TSchema, TRelation, T extends TSchema[keyof TSchema]> =
type BackRelation<TSchema, TRelation, T extends TSchema[keyof TSchema]> = keyof {
[Key in keyof TRelation as Key extends `${string}(${infer U})` | `${string}_via_${infer U}`
? U extends keyof TRelation
? TRelation[U] extends T
? T extends TRelation[U]
? Key
: never
: never
Expand Down

0 comments on commit 84258cd

Please sign in to comment.