Files
adam-acs/app/models/migration_route.ts
T
Kevin L'HereecandCopilot d1c65dbf1e chore: initial commit — AdonisJS v7 TR-069 ACS
- Docker infrastructure (Dockerfile, docker-compose.yml, genieacs-sim)
- AdonisJS v7 app with Inertia.js + Vue 3
- MongoDB integration
- CWMP/TR-069 state machine engine
- Configuration engine with compliance tracking
- Branding: ADAM ACS (favicon, navbar, locales)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-05-29 16:46:37 +02:00

32 lines
1.1 KiB
TypeScript

import { BaseModel } from '#database/base_model'
import { MigrationRoute } from '../domain/firmware/firmware_catalog.js'
import { Sort } from 'mongodb'
export default class MigrationRouteModel extends BaseModel {
static collectionName = 'migration_routes'
static async findByIdentifier(identifier: string): Promise<MigrationRoute | null> {
return this.findOne({ identifier }) as Promise<MigrationRoute | null>
}
static async findByProductClass(
productClass: string,
sort: Sort = { priority: -1 }
): Promise<MigrationRoute[]> {
const collection = this.getCollection()
return collection.find({ productClass }).sort(sort).toArray() as unknown as Promise<MigrationRoute[]>
}
static async createIfNotExists(data: Partial<MigrationRoute>): Promise<MigrationRoute> {
const existing = await this.findOne({ identifier: data.identifier })
if (existing) {
throw new Error(`Migration route with identifier '${data.identifier}' already exists`)
}
return this.create(data) as Promise<MigrationRoute>
}
static async deleteByIdentifier(identifier: string): Promise<boolean> {
return this.deleteOne({ identifier })
}
}