postgresdk 0.16.14 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -0
- package/dist/cache.d.ts +34 -0
- package/dist/cli.js +572 -130
- package/dist/emit-sdk-contract.d.ts +0 -1
- package/dist/index.js +504 -108
- package/dist/utils.d.ts +16 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -736,6 +736,48 @@ do {
|
|
|
736
736
|
if (!page.hasMore) break;
|
|
737
737
|
} while (true);
|
|
738
738
|
|
|
739
|
+
// Field filtering with select/exclude
|
|
740
|
+
const withSelect = await sdk.users.list({
|
|
741
|
+
select: ['id', 'email', 'name'], // Only return these fields
|
|
742
|
+
limit: 10
|
|
743
|
+
});
|
|
744
|
+
// Result: { data: [{ id, email, name }], total, ... }
|
|
745
|
+
|
|
746
|
+
const withExclude = await sdk.users.list({
|
|
747
|
+
exclude: ['password_hash', 'secret_token'], // Return all fields except these
|
|
748
|
+
where: { status: 'active' }
|
|
749
|
+
});
|
|
750
|
+
// Result: All fields except password_hash and secret_token
|
|
751
|
+
|
|
752
|
+
// Select/exclude on single record operations
|
|
753
|
+
const created = await sdk.users.create(
|
|
754
|
+
{ email: 'user@example.com', name: 'Alice' },
|
|
755
|
+
{ select: ['id', 'email'] } // Only return id and email
|
|
756
|
+
);
|
|
757
|
+
|
|
758
|
+
const updated = await sdk.users.update(
|
|
759
|
+
userId,
|
|
760
|
+
{ name: 'Bob' },
|
|
761
|
+
{ exclude: ['created_at', 'updated_at'] }
|
|
762
|
+
);
|
|
763
|
+
|
|
764
|
+
const fetched = await sdk.users.getByPk(userId, { select: ['id', 'name'] });
|
|
765
|
+
const deleted = await sdk.users.delete(userId, { select: ['id', 'email'] });
|
|
766
|
+
|
|
767
|
+
// Nested select/exclude in includes
|
|
768
|
+
const withNestedSelect = await sdk.authors.list({
|
|
769
|
+
select: ['id', 'name'],
|
|
770
|
+
include: {
|
|
771
|
+
books: {
|
|
772
|
+
select: ['id', 'title'], // Filter included books too
|
|
773
|
+
orderBy: 'published_at',
|
|
774
|
+
order: 'desc',
|
|
775
|
+
limit: 5
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
// Result: authors with only id/name, books with only id/title
|
|
780
|
+
|
|
739
781
|
// JSONB queries
|
|
740
782
|
const products = await sdk.products.list({
|
|
741
783
|
where: {
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Model } from "./introspect";
|
|
2
|
+
import type { Config } from "./types";
|
|
3
|
+
export interface CacheData {
|
|
4
|
+
schemaHash: string;
|
|
5
|
+
lastRun: string;
|
|
6
|
+
filesGenerated: number;
|
|
7
|
+
config: {
|
|
8
|
+
outDir: string | {
|
|
9
|
+
server: string;
|
|
10
|
+
client: string;
|
|
11
|
+
};
|
|
12
|
+
schema: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Compute a deterministic hash of the schema and config
|
|
17
|
+
*/
|
|
18
|
+
export declare function computeSchemaHash(model: Model, config: Config): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get the cache directory path
|
|
21
|
+
*/
|
|
22
|
+
export declare function getCacheDir(baseDir?: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Read cache data if it exists
|
|
25
|
+
*/
|
|
26
|
+
export declare function readCache(baseDir?: string): Promise<CacheData | null>;
|
|
27
|
+
/**
|
|
28
|
+
* Write cache data
|
|
29
|
+
*/
|
|
30
|
+
export declare function writeCache(data: CacheData, baseDir?: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Append an entry to the history log
|
|
33
|
+
*/
|
|
34
|
+
export declare function appendToHistory(entry: string, baseDir?: string): Promise<void>;
|