- 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>
35 lines
1.3 KiB
TypeScript
35 lines
1.3 KiB
TypeScript
import { BaseModel } from '#database/base_model'
|
|
import { FirmwareEntry } from '../domain/firmware/firmware_catalog.js'
|
|
|
|
export default class FirmwareEntryModel extends BaseModel {
|
|
static collectionName = 'firmware_entries'
|
|
|
|
static async findByIdentifier(identifier: string): Promise<FirmwareEntry | null> {
|
|
return this.findOne({ identifier }) as Promise<FirmwareEntry | null>
|
|
}
|
|
|
|
static async findByProductClass(productClass: string): Promise<FirmwareEntry[]> {
|
|
const collection = this.getCollection()
|
|
return collection.find({ productClass }).toArray() as unknown as Promise<FirmwareEntry[]>
|
|
}
|
|
|
|
static async findByProductClassAndVersion(
|
|
productClass: string,
|
|
version: string
|
|
): Promise<FirmwareEntry | null> {
|
|
return this.findOne({ productClass, version }) as Promise<FirmwareEntry | null>
|
|
}
|
|
|
|
static async createIfNotExists(data: Partial<FirmwareEntry>): Promise<FirmwareEntry> {
|
|
const existing = await this.findOne({ identifier: data.identifier })
|
|
if (existing) {
|
|
throw new Error(`Firmware entry with identifier '${data.identifier}' already exists`)
|
|
}
|
|
return this.create(data) as Promise<FirmwareEntry>
|
|
}
|
|
|
|
static async deleteByIdentifier(identifier: string): Promise<boolean> {
|
|
return this.deleteOne({ identifier })
|
|
}
|
|
}
|