tswow/tswow-scripts/data/table/PrimaryKey.ts
2022-02-11 15:00:55 +01:00

26 lines
998 B
TypeScript

/*
* This file is part of tswow (https://github.com/tswow)
*
* Copyright (C) 2020 tswow <https://github.com/tswow/>
* 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, version 3.
*
* 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, see <https://www.gnu.org/licenses/>.
*/
export const PKFIELDS_FIELD = '_pkfields';
export function PrimaryKey(keyname?: string) {
return function(target: any, field: any) {
if (target[PKFIELDS_FIELD] === undefined) {
target[PKFIELDS_FIELD] = [];
}
target[PKFIELDS_FIELD].push(field);
};
}