auth with admin

This commit is contained in:
MDeghaud67 2023-04-24 11:05:54 +02:00
parent 824276bc07
commit bccceafeec
6 changed files with 64 additions and 0 deletions

View File

@ -0,0 +1,7 @@
import PocketBase from 'pocketbase';
const pb = new PocketBase('http://127.0.0.1:8090');
await pb.admins.authWithPassword('test@example.com', '123456');
const admin = await pb.admins.getOne('ADMIN_ID');

View File

@ -0,0 +1,18 @@
import PocketBase from 'pocketbase';
const pb = new PocketBase('http://127.0.0.1:8090');
...
await pb.admins.authWithPassword('test@example.com', '123456');
// fetch a paginated records list
const resultList = await pb.admins.getList(1, 100, {
filter: 'created >= '2022-01-01 00:00:00'',
});
// you can also fetch all records at once via getFullList
const admins = await pb.admins.getFullList({ sort: '-created' });
// or fetch only the first admin that matches the specified filter
const admin = await pb.admins.getFirstListItem('email~"test"');

View File

@ -0,0 +1,16 @@
import PocketBase from 'pocketbase';
const pb = new PocketBase('http://127.0.0.1:8090');
await pb.admins.authWithPassword('test@example.com', '123456');
// fetch a paginated records list
const resultList = await pb.admins.getList(1, 100, {
filter: 'created >= \'2022-01-01 00:00:00\'',
});
// you can also fetch all records at once via getFullList
const admins = await pb.admins.getFullList({ sort: '-created' });
// or fetch only the first admin that matches the specified filter
const admin = await pb.admins.getFirstListItem('email~"test"');

View File

@ -0,0 +1,7 @@
import PocketBase from 'pocketbase';
const pb = new PocketBase('http://127.0.0.1:8090');
await pb.admins.authWithPassword('test@example.com', '123456');
const admin = await pb.admins.getOne('ADMIN_ID');

View File

@ -0,0 +1,16 @@
import PocketBase from 'pocketbase';
const pb = new PocketBase('http://127.0.0.1:8090');
await pb.admins.authWithPassword('test@example.com', '123456');
// fetch a paginated records list
const resultList = await pb.admins.getList(1, 100, {
filter: 'created >= \'2022-01-01 00:00:00\'',
});
// you can also fetch all records at once via getFullList
const admins = await pb.admins.getFullList({ sort: '-created' });
// or fetch only the first admin that matches the specified filter
const admin = await pb.admins.getFirstListItem('email~"test"');