refactor(appwrite/dynamic-data): use native API ordering
This commit is contained in:
@@ -12,15 +12,26 @@ export default {
|
||||
return collections;
|
||||
}
|
||||
|
||||
const params = {
|
||||
queries: [
|
||||
JSON.stringify({
|
||||
method: 'orderAsc',
|
||||
atttribute: 'name'
|
||||
}),
|
||||
JSON.stringify({
|
||||
method: 'limit',
|
||||
values: [100]
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const { data } = await $.http.get(
|
||||
`/v1/databases/${databaseId}/collections`
|
||||
`/v1/databases/${databaseId}/collections`,
|
||||
{ params }
|
||||
);
|
||||
|
||||
if (data?.collections) {
|
||||
const sortedCollections = data.collections.sort((a, b) =>
|
||||
a.$createdAt - b.$createdAt ? 1 : -1
|
||||
);
|
||||
for (const collection of sortedCollections) {
|
||||
for (const collection of data.collections) {
|
||||
collections.data.push({
|
||||
value: collection.$id,
|
||||
name: collection.name,
|
||||
|
@@ -7,13 +7,23 @@ export default {
|
||||
data: [],
|
||||
};
|
||||
|
||||
const { data } = await $.http.get('/v1/databases');
|
||||
const params = {
|
||||
queries: [
|
||||
JSON.stringify({
|
||||
method: 'orderAsc',
|
||||
atttribute: 'name'
|
||||
}),
|
||||
JSON.stringify({
|
||||
method: 'limit',
|
||||
values: [100]
|
||||
}),
|
||||
],
|
||||
};
|
||||
|
||||
const { data } = await $.http.get('/v1/databases', { params });
|
||||
|
||||
if (data?.databases) {
|
||||
const sortedDatabases = data.databases.sort((a, b) =>
|
||||
a.$createdAt - b.$createdAt ? 1 : -1
|
||||
);
|
||||
for (const database of sortedDatabases) {
|
||||
for (const database of data.databases) {
|
||||
databases.data.push({
|
||||
value: database.$id,
|
||||
name: database.name,
|
||||
|
Reference in New Issue
Block a user