postgresdk 0.17.0 → 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/cli.js +333 -57
- package/dist/index.js +333 -57
- 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: {
|