Browse Source

sort database

Signed-off-by: ruiyi.jiang <ruiyi.jiang@zilliz.com>
ruiyi.jiang 1 year ago
parent
commit
9724103221
1 changed files with 9 additions and 0 deletions
  1. 9 0
      server/src/database/databases.controller.ts

+ 9 - 0
server/src/database/databases.controller.ts

@@ -46,6 +46,15 @@ export class DatabasesController {
   async listDatabases(req: Request, res: Response, next: NextFunction) {
     try {
       const result = await this.databasesService.listDatabase();
+      result.db_names = result.db_names.sort((a: string, b: string) => {
+        if (a === 'default') {
+          return -1; // 'default' comes before other strings
+        } else if (b === 'default') {
+          return 1; // 'default' comes after other strings
+        } else {
+          return a.localeCompare(b); // sort other strings alphabetically
+        }
+      })
       res.send(result);
     } catch (error) {
       next(error);