mirror of
https://github.com/utopia-os/utopia-ui.git
synced 2025-12-13 07:46:10 +00:00
extended api
This commit is contained in:
parent
109a4eccae
commit
968e7303d4
@ -9,6 +9,11 @@ export type Place = {
|
||||
text: string;
|
||||
position?: Point;
|
||||
};
|
||||
|
||||
export type Tag = {
|
||||
id: string;
|
||||
color: string;
|
||||
};
|
||||
|
||||
export type Event = {
|
||||
id: string;
|
||||
|
||||
@ -17,30 +17,34 @@ export class itemsApi<T> implements ItemsApi<T>{
|
||||
return await directusClient.request(readItems(this.collectionName as never,{limit: 500 }));
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw new Error("Failed while loading items");
|
||||
}
|
||||
}
|
||||
|
||||
async createItem(item: T & { id?: string }) {
|
||||
async createItem(item: T & { id?: string }) {
|
||||
try {
|
||||
return await directusClient.request(createItem(this.collectionName as keyof MyCollections,item))
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
throw new Error(error.errors[0].message);
|
||||
}
|
||||
}
|
||||
|
||||
async updateItem(item: T & { id?: string }) {
|
||||
try {
|
||||
return await directusClient.request(updateItem(this.collectionName as keyof MyCollections,item.id!, item))
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
throw new Error(error.errors[0].message);
|
||||
}
|
||||
}
|
||||
|
||||
async deleteItem(id: string ) {
|
||||
try {
|
||||
return await directusClient.request(deleteItem(this.collectionName as keyof MyCollections,id))
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.log(error);
|
||||
throw new Error(error.errors[0].message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user