updated api preview docs
This commit is contained in:
@@ -7,22 +7,15 @@
|
||||
|
||||
export let collection = new Collection();
|
||||
|
||||
let responseTab = 200;
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
|
||||
|
||||
$: responses = [
|
||||
{
|
||||
code: 200,
|
||||
body: JSON.stringify(
|
||||
{
|
||||
token: "JWT_TOKEN",
|
||||
record: CommonHelper.dummyCollectionRecord(collection),
|
||||
},
|
||||
null,
|
||||
2
|
||||
),
|
||||
code: 204,
|
||||
body: "null",
|
||||
},
|
||||
{
|
||||
code: 400,
|
||||
@@ -45,7 +38,6 @@
|
||||
<h3 class="m-b-sm">Confirm email change ({collection.name})</h3>
|
||||
<div class="content txt-lg m-b-sm">
|
||||
<p>Confirms <strong>{collection.name}</strong> email change request.</p>
|
||||
<p>Returns the refreshed auth data.</p>
|
||||
</div>
|
||||
|
||||
<SdkTabs
|
||||
@@ -56,15 +48,10 @@
|
||||
|
||||
...
|
||||
|
||||
const authData = await pb.collection('${collection?.name}').confirmEmailChange(
|
||||
await pb.collection('${collection?.name}').confirmEmailChange(
|
||||
'TOKEN',
|
||||
'YOUR_PASSWORD',
|
||||
);
|
||||
|
||||
// after the above you can also access the auth data from the authStore
|
||||
console.log(pb.authStore.isValid);
|
||||
console.log(pb.authStore.token);
|
||||
console.log(pb.authStore.model.id);
|
||||
`}
|
||||
dart={`
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
@@ -73,15 +60,10 @@
|
||||
|
||||
...
|
||||
|
||||
final authData = await pb.collection('${collection?.name}').confirmEmailChange(
|
||||
await pb.collection('${collection?.name}').confirmEmailChange(
|
||||
'TOKEN',
|
||||
'YOUR_PASSWORD',
|
||||
);
|
||||
|
||||
// after the above you can also access the auth data from the authStore
|
||||
console.log(pb.authStore.isValid);
|
||||
console.log(pb.authStore.token);
|
||||
console.log(pb.authStore.model.id);
|
||||
`}
|
||||
/>
|
||||
|
||||
|
||||
@@ -7,22 +7,15 @@
|
||||
|
||||
export let collection = new Collection();
|
||||
|
||||
let responseTab = 200;
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
|
||||
|
||||
$: responses = [
|
||||
{
|
||||
code: 200,
|
||||
body: JSON.stringify(
|
||||
{
|
||||
token: "JWT_TOKEN",
|
||||
record: CommonHelper.dummyCollectionRecord(collection),
|
||||
},
|
||||
null,
|
||||
2
|
||||
),
|
||||
code: 204,
|
||||
body: "null",
|
||||
},
|
||||
{
|
||||
code: 400,
|
||||
@@ -45,7 +38,6 @@
|
||||
<h3 class="m-b-sm">Confirm password reset ({collection.name})</h3>
|
||||
<div class="content txt-lg m-b-sm">
|
||||
<p>Confirms <strong>{collection.name}</strong> password reset request.</p>
|
||||
<p>Returns the refreshed auth data.</p>
|
||||
</div>
|
||||
|
||||
<SdkTabs
|
||||
@@ -56,16 +48,11 @@
|
||||
|
||||
...
|
||||
|
||||
const authData = await pb.collection('${collection?.name}').confirmPasswordReset(
|
||||
await pb.collection('${collection?.name}').confirmPasswordReset(
|
||||
'TOKEN',
|
||||
'NEW_PASSWORD',
|
||||
'NEW_PASSWORD_CONFIRM',
|
||||
);
|
||||
|
||||
// after the above you can also access the refreshed auth data from the authStore
|
||||
console.log(pb.authStore.isValid);
|
||||
console.log(pb.authStore.token);
|
||||
console.log(pb.authStore.model.id);
|
||||
`}
|
||||
dart={`
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
@@ -74,16 +61,11 @@
|
||||
|
||||
...
|
||||
|
||||
final authData = await pb.collection('${collection?.name}').confirmPasswordReset(
|
||||
await pb.collection('${collection?.name}').confirmPasswordReset(
|
||||
'TOKEN',
|
||||
'NEW_PASSWORD',
|
||||
'NEW_PASSWORD_CONFIRM',
|
||||
);
|
||||
|
||||
// after the above you can also access the refreshed auth data from the authStore
|
||||
console.log(pb.authStore.isValid);
|
||||
console.log(pb.authStore.token);
|
||||
console.log(pb.authStore.model.id);
|
||||
`}
|
||||
/>
|
||||
|
||||
|
||||
@@ -7,22 +7,15 @@
|
||||
|
||||
export let collection = new Collection();
|
||||
|
||||
let responseTab = 200;
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
|
||||
|
||||
$: responses = [
|
||||
{
|
||||
code: 200,
|
||||
body: JSON.stringify(
|
||||
{
|
||||
token: "JWT_TOKEN",
|
||||
record: CommonHelper.dummyCollectionRecord(collection),
|
||||
},
|
||||
null,
|
||||
2
|
||||
),
|
||||
code: 204,
|
||||
body: "null",
|
||||
},
|
||||
{
|
||||
code: 400,
|
||||
@@ -45,7 +38,6 @@
|
||||
<h3 class="m-b-sm">Confirm verification ({collection.name})</h3>
|
||||
<div class="content txt-lg m-b-sm">
|
||||
<p>Confirms <strong>{collection.name}</strong> account verification request.</p>
|
||||
<p>Returns the refreshed auth data.</p>
|
||||
</div>
|
||||
|
||||
<SdkTabs
|
||||
@@ -56,12 +48,7 @@
|
||||
|
||||
...
|
||||
|
||||
const authData = await pb.collection('${collection?.name}').confirmVerification('TOKEN');
|
||||
|
||||
// after the above you can also access the auth data from the authStore
|
||||
console.log(pb.authStore.isValid);
|
||||
console.log(pb.authStore.token);
|
||||
console.log(pb.authStore.model.id);
|
||||
await pb.collection('${collection?.name}').confirmVerification('TOKEN');
|
||||
`}
|
||||
dart={`
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
@@ -70,12 +57,7 @@
|
||||
|
||||
...
|
||||
|
||||
final authData = await pb.collection('${collection?.name}').confirmVerification('TOKEN');
|
||||
|
||||
// after the above you can also access the auth data from the authStore
|
||||
console.log(pb.authStore.isValid);
|
||||
console.log(pb.authStore.token);
|
||||
console.log(pb.authStore.model.id);
|
||||
await pb.collection('${collection?.name}').confirmVerification('TOKEN');
|
||||
`}
|
||||
/>
|
||||
|
||||
|
||||
@@ -91,9 +91,9 @@
|
||||
filter: 'created >= "2022-01-01 00:00:00" && someFiled1 != someField2',
|
||||
});
|
||||
|
||||
// you can also fetch all records at once via getFullList:
|
||||
// you can also fetch all records at once via getFullList
|
||||
const records = await pb.collection('${collection?.name}').getFullList(200 /* batch size */, {
|
||||
sort: '-created'
|
||||
sort: '-created',
|
||||
});
|
||||
|
||||
// or fetch only the first record that matches the specified filter
|
||||
@@ -122,7 +122,7 @@
|
||||
);
|
||||
|
||||
// or fetch only the first record that matches the specified filter
|
||||
final record2 = await pb.collection('${collection?.name}').getFirstListItem(
|
||||
final record = await pb.collection('${collection?.name}').getFirstListItem(
|
||||
'someField="test"',
|
||||
expand: 'relField1,relField2.subRelField',
|
||||
);
|
||||
|
||||
@@ -50,19 +50,20 @@
|
||||
// (Optionally) authenticate
|
||||
await pb.collection('users').authWithPassword('test@example.com', '123456');
|
||||
|
||||
// Subscribe to changes in any record from the collection
|
||||
pb.collection('${collection?.name}').subscribe(function (e) {
|
||||
// Subscribe to changes in any ${collection?.name} record
|
||||
pb.collection('${collection?.name}').subscribe('*', function (e) {
|
||||
console.log(e.record);
|
||||
});
|
||||
|
||||
// Subscribe to changes in a single record
|
||||
// Subscribe to changes only in the specified record
|
||||
pb.collection('${collection?.name}').subscribeOne('RECORD_ID', function (e) {
|
||||
console.log(e.record);
|
||||
});
|
||||
|
||||
// Unsubscribe
|
||||
pb.collection('${collection?.name}').unsubscribe() // remove all collection subscriptions
|
||||
pb.collection('${collection?.name}').unsubscribe('RECORD_ID') // remove only the record subscription
|
||||
pb.collection('${collection?.name}').unsubscribe('RECORD_ID'); // remove all 'RECORD_ID' subscriptions
|
||||
pb.collection('${collection?.name}').unsubscribe('*'); // remove all '*' topic subscriptions
|
||||
pb.collection('${collection?.name}').unsubscribe(); // remove all subscriptions in the collection
|
||||
`}
|
||||
dart={`
|
||||
import 'package:pocketbase/pocketbase.dart';
|
||||
@@ -74,19 +75,20 @@
|
||||
// (Optionally) authenticate
|
||||
await pb.collection('users').authWithPassword('test@example.com', '123456');
|
||||
|
||||
// Subscribe to changes in any record from the collection
|
||||
pb.collection('${collection?.name}').subscribe((e) {
|
||||
print(e.record);
|
||||
// Subscribe to changes in any ${collection?.name} record
|
||||
pb.collection('${collection?.name}').subscribe('*', (e) {
|
||||
console.log(e.record);
|
||||
});
|
||||
|
||||
// Subscribe to changes in a single record
|
||||
// Subscribe to changes only in the specified record
|
||||
pb.collection('${collection?.name}').subscribeOne('RECORD_ID', (e) {
|
||||
print(e.record);
|
||||
console.log(e.record);
|
||||
});
|
||||
|
||||
// Unsubscribe
|
||||
pb.collection('${collection?.name}').unsubscribe() // remove all collection subscriptions
|
||||
pb.collection('${collection?.name}').unsubscribe('RECORD_ID') // remove only the record subscription
|
||||
pb.collection('${collection?.name}').unsubscribe('RECORD_ID'); // remove all 'RECORD_ID' subscriptions
|
||||
pb.collection('${collection?.name}').unsubscribe('*'); // remove all '*' topic subscriptions
|
||||
pb.collection('${collection?.name}').unsubscribe(); // remove all subscriptions in the collection
|
||||
`}
|
||||
/>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user