@ts-awesome/orm 1.5.11 → 1.6.0-rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/tests/models.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { dbField, dbTable, IDbField, dbFilterField, and, Select } from '../src';
1
+ import {dbField, dbTable, IDbField, dbFilterField, and, Select, DbValueType, IOperandable, cast} from '../src';
2
2
 
3
3
  const UUID: IDbField = {}
4
4
 
@@ -61,3 +61,28 @@ export class Employee {
61
61
  @dbField company!: string;
62
62
  @dbField salary!: number;
63
63
  }
64
+
65
+ export const EMAIL: IDbField = {
66
+ reader(value: DbValueType) {
67
+ return typeof value === 'string' ? value.toLowerCase() : value
68
+ },
69
+ writer(value): DbValueType {
70
+ return typeof value === 'string' ? value.toLowerCase() : value
71
+ },
72
+ readQuery(name: IOperandable<string>): IOperandable<string> {
73
+ return cast(name as never, 'Email');
74
+ },
75
+ writeQuery(name: IOperandable<string>): IOperandable<string> {
76
+ return cast(name as never, 'Email');
77
+ }
78
+ }
79
+
80
+ export class MailingList {
81
+ @dbField({
82
+ primaryKey: true,
83
+ autoIncrement: true
84
+ })
85
+ public id!: number;
86
+ @dbField public name!: string;
87
+ @dbField({kind: EMAIL}) email!: string;
88
+ }