ts-db-helper
Version:
Simple ORM based on TypeScript
45 lines • 1.07 kB
JavaScript
import { Column } from './column';
/**
* @public
* @function PrimaryKey
*
* @description
* annotation factory to add on class property that should use {@link Table} annotation.
* class using this annotation must extends {@link DbHelperModel}.
*
* @example
* ```typescript
* @Table()
* export class Todo extends DbHelperModel {
*
* @PrimaryKey({autoIncremented: true})
* public id: number
*
* @Column()
* public name: string;
*
* @Column({type: 'long'})
* public dueDate: number;
* }
* ```
*
* @template T @extends DbHelperModel the target model
*
* @param {ColumConfig} config is column configuration, informations are used to
* build DataModel.
*
* @return {Function} the annotation
*
* @author Olivier Margarit
* @since 0.1
*/
export function PrimaryKey(config) {
if (config) {
config.primaryKey = true;
}
else {
config = { primaryKey: true };
}
return Column(config);
}
//# sourceMappingURL=primary-key.js.map