[#166] fixed api preview examples

This commit is contained in:
Gani Georgiev
2022-07-19 19:41:03 +03:00
parent 66b317f01c
commit 8a08a4764d
13 changed files with 56 additions and 82 deletions
@@ -53,14 +53,11 @@
const client = new PocketBase("${ApiClient.baseUrl}");
...
const data = { ... };
client.Records.create("${collection?.name}", data)
.then(function (record) {
// success...
}).catch(function (error) {
// error...
});
const record = await client.Records.create("${collection?.name}", data);
`,
},
];
@@ -64,12 +64,9 @@
const client = new PocketBase("${ApiClient.baseUrl}");
client.Records.delete("${collection?.name}", "RECORD_ID")
.then(function () {
// success...
}).catch(function (error) {
// error...
});
...
await client.Records.delete("${collection?.name}", "RECORD_ID");
`,
},
];
@@ -76,20 +76,17 @@
const client = new PocketBase("${ApiClient.baseUrl}");
client.Records.getList("${collection?.name}", { page: 2 })
.then(function (list) {
// success...
}).catch(function (error) {
// error...
});
...
// fetch a paginated records list
const resultList = await client.Records.getList("${collection?.name}", 1, 50, {
filter: "created >= '2022-01-01 00:00:00'",
});
// alternatively you can also fetch all records at once via getFullList:
client.Records.getFullList("${collection?.name}", 200 /* batch size */)
.then(function (records) {
// success...
}).catch(function (error) {
// error...
});
const records = await client.Records.getFullList("${collection?.name}", 200 /* batch size */, {
sort: "-created",
});
`,
},
];
@@ -63,14 +63,11 @@
const client = new PocketBase("${ApiClient.baseUrl}");
...
const data = { ... };
client.Records.update("${collection?.name}", "RECORD_ID", data)
.then(function (record) {
// success...
}).catch(function (error) {
// error...
});
const record = await client.Records.update("${collection?.name}", "RECORD_ID", data);
`,
},
];
@@ -52,12 +52,11 @@
const client = new PocketBase("${ApiClient.baseUrl}");
client.Records.getOne("${collection?.name}", "RECORD_ID")
.then(function (record) {
// success...
}).catch(function (error) {
// error...
});
...
const record = await client.Records.getOne("${collection?.name}", "RECORD_ID", {
expand: "some_relation"
});
`,
},
];