- 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>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { BaseModel } from '#database/base_model'
|
|
import { ConfigurationVersion } from '../domain/configuration/configuration_version.js'
|
|
import { Sort } from 'mongodb'
|
|
|
|
export default class ConfigurationVersionModel extends BaseModel {
|
|
static collectionName = 'configuration_versions'
|
|
|
|
static async findByConfigurationIdentifier(
|
|
configurationIdentifier: string,
|
|
sort: Sort = { versionNumber: -1 }
|
|
): Promise<ConfigurationVersion[]> {
|
|
const collection = this.getCollection()
|
|
return collection
|
|
.find({ configurationIdentifier })
|
|
.sort(sort)
|
|
.toArray() as unknown as Promise<ConfigurationVersion[]>
|
|
}
|
|
|
|
static async paginateVersions(
|
|
configurationIdentifier: string,
|
|
page: number,
|
|
perPage: number
|
|
): Promise<{ data: ConfigurationVersion[]; total: number; page: number; perPage: number; lastPage: number }> {
|
|
return this.paginate(page, perPage, { configurationIdentifier }, { versionNumber: -1 })
|
|
}
|
|
|
|
static async getLatestVersionNumber(configurationIdentifier: string): Promise<number> {
|
|
const collection = this.getCollection()
|
|
const latest = await collection
|
|
.find({ configurationIdentifier })
|
|
.sort({ versionNumber: -1 })
|
|
.limit(1)
|
|
.toArray()
|
|
return latest.length > 0 ? (latest[0] as any).versionNumber : 0
|
|
}
|
|
|
|
static async deleteByConfigurationIdentifier(configurationIdentifier: string): Promise<number> {
|
|
return this.deleteMany({ configurationIdentifier })
|
|
}
|
|
}
|