From aaa2a92248cd8b737965a6707cf5e3a17a47ea97 Mon Sep 17 00:00:00 2001 From: David Kellner <52860029+kellnerd@users.noreply.github.com> Date: Wed, 24 Jul 2024 20:27:45 +0200 Subject: [PATCH] feat(imports): Add model for imported series --- src/index.ts | 2 ++ src/models/imports/seriesImport.ts | 34 ++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/models/imports/seriesImport.ts diff --git a/src/index.ts b/src/index.ts index a9a8330d..7da0158d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -85,6 +85,7 @@ import revision from './models/revision'; import series from './models/entities/series'; import seriesData from './models/data/seriesData'; import seriesHeader from './models/headers/seriesHeader'; +import seriesImport from './models/imports/seriesImport'; import seriesOrderingType from './models/seriesOrderingType'; import seriesRevision from './models/revisions/seriesRevision'; import titleType from './models/titleType'; @@ -180,6 +181,7 @@ export default function init(config: Knex.Config) { Series: series(bookshelf), SeriesData, SeriesHeader: seriesHeader(bookshelf), + SeriesImport: seriesImport(bookshelf), SeriesOrderingType: seriesOrderingType(bookshelf), SeriesRevision: seriesRevision(bookshelf), TitleType: titleType(bookshelf), diff --git a/src/models/imports/seriesImport.ts b/src/models/imports/seriesImport.ts new file mode 100644 index 00000000..3b76bdce --- /dev/null +++ b/src/models/imports/seriesImport.ts @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2024 David Kellner + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +import type Bookshelf from '@metabrainz/bookshelf'; + + +export default function series(bookshelf: Bookshelf) { + const SeriesData = bookshelf.model('SeriesData'); + + const SeriesImport = SeriesData.extend({ + defaultAlias() { + return this.belongsTo('Alias', 'default_alias_id'); + }, + idAttribute: 'import_id', + tableName: 'bookbrainz.series_import' + }); + + return bookshelf.model('SeriesImport', SeriesImport); +}