Refactor app management to use Drizzle ORM
- Replaced Sequelize models with Drizzle ORM for app and app list management. - Updated routes in app-manager to utilize new database queries. - Removed obsolete Sequelize model files for app, app list, and app domain. - Introduced new helper functions for app and app domain management. - Enhanced user app management with improved file handling and user migration. - Adjusted public API routes to align with new database structure. - Implemented caching mechanisms for domain management.
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
import { AppModel } from '../module/index.ts';
|
||||
import { db, schema } from '@/app.ts';
|
||||
import { eq } from 'drizzle-orm';
|
||||
|
||||
export const mvAppFromUserAToUserB = async (userA: string, userB: string) => {
|
||||
const appList = await AppModel.findAll({
|
||||
where: {
|
||||
user: userA,
|
||||
},
|
||||
});
|
||||
const appList = await db.select().from(schema.kvApp).where(eq(schema.kvApp.user, userA));
|
||||
for (const app of appList) {
|
||||
app.user = userB;
|
||||
await app.save();
|
||||
await db.update(schema.kvApp)
|
||||
.set({ user: userB, updatedAt: new Date().toISOString() })
|
||||
.where(eq(schema.kvApp.id, app.id));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user