var rename
This commit is contained in:
parent
6d708d8fd4
commit
7b98506ad5
@ -8,29 +8,29 @@ import {
|
||||
} from './schema'
|
||||
|
||||
class APIClient {
|
||||
client: Pocketbase
|
||||
pb: Pocketbase
|
||||
|
||||
constructor() {
|
||||
this.client = new Pocketbase("http://localhost:4321")
|
||||
this.client.autoCancellation(false)
|
||||
this.pb = new Pocketbase("http://localhost:4321")
|
||||
this.pb.autoCancellation(false)
|
||||
}
|
||||
|
||||
async getRecipesPage(page: number, perPage: number = 30, options: RecordListOptions) {
|
||||
return await this.client.collection<Recipe>(Collection.RECIPES).getList(page, perPage, options)
|
||||
return await this.pb.collection<Recipe>(Collection.RECIPES).getList(page, perPage, options)
|
||||
}
|
||||
|
||||
async getAllRecipes() {
|
||||
return await this.client.collection<Recipe>(Collection.RECIPES).getFullList({ expand: 'ingredients,tags,steps,images,steps.ingredients' })
|
||||
return await this.pb.collection<Recipe>(Collection.RECIPES).getFullList({ expand: 'ingredients,tags,steps,images,steps.ingredients' })
|
||||
}
|
||||
|
||||
async getRecipe(id: string) {
|
||||
return await this.client.collection<Recipe>(Collection.RECIPES).getOne(id, { expand: 'ingredients,tags,steps,images,steps.ingredients' })
|
||||
return await this.pb.collection<Recipe>(Collection.RECIPES).getOne(id, { expand: 'ingredients,tags,steps,images,steps.ingredients' })
|
||||
}
|
||||
|
||||
// IMAGE
|
||||
async getImageURL(imgID: string, relative: boolean = true) {
|
||||
const record = await this.client.collection(Collection.IMAGES).getOne(imgID)
|
||||
const res = this.client.files.getURL(record, record.image)
|
||||
const record = await this.pb.collection(Collection.IMAGES).getOne(imgID)
|
||||
const res = this.pb.files.getURL(record, record.image)
|
||||
return relative ? res.substring(21) : res
|
||||
}
|
||||
|
||||
@ -45,11 +45,11 @@ class APIClient {
|
||||
}
|
||||
|
||||
async getAllTags() {
|
||||
return await this.client.collection<Tag>(Collection.TAGS).getFullList()
|
||||
return await this.pb.collection<Tag>(Collection.TAGS).getFullList()
|
||||
}
|
||||
|
||||
async getTag(name: string) {
|
||||
return await this.client.collection<Tag>(Collection.TAGS).getList(1, 50, { filter: `name = '${name}'` })
|
||||
return await this.pb.collection<Tag>(Collection.TAGS).getList(1, 50, { filter: `name = '${name}'` })
|
||||
}
|
||||
|
||||
async getRecipesOfTag(tagName: string) {
|
||||
@ -60,7 +60,7 @@ class APIClient {
|
||||
}
|
||||
const tag = tagResult.items[0]
|
||||
|
||||
return await this.client.collection<Recipe>(Collection.RECIPES).getFullList({
|
||||
return await this.pb.collection<Recipe>(Collection.RECIPES).getFullList({
|
||||
filter: `tags ~ '${tag.id}'`,
|
||||
expand: 'ingredients,tags,steps,images,steps.ingredients'
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user