-
Notifications
You must be signed in to change notification settings - Fork 0
/
map.js
50 lines (44 loc) · 1.47 KB
/
map.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import orange from 'orange-orm';
const map = orange.map(x => {
return {
order: x.table('_order').map(v => {
return {
id: v.column('id').numeric().primary(),
orderDate: v.column('orderDate').date(),
customerId: v.column('customerId').numeric()
}
}),
orderLine: x.table('orderLine').map(v => {
return {
id: v.column('id').numeric().primary(),
orderId: v.column('orderId').numeric(),
product: v.column('product').string(),
amount: v.column('amount').numeric(),
}
}),
deliveryAddress: x.table('deliveryAddress').map(v => {
return {
id: v.column('id').numeric().primary(),
orderId: v.column('orderId').numeric(),
postalPlace: v.column('postalPlace').string(),
}
}),
customer: x.table('customer').map(v => {
return {
id: v.column('id').numeric().primary(),
name: v.column('name').string(),
}
})
}
}).map(x => {
return {
order: x.order.map(v => {
return {
deliveryAddress: v.hasOne(x.deliveryAddress).by('orderId'),
customer: v.references(x.customer).by('customerId'),
lines: v.hasMany(x.orderLine).by('orderId'),
};
})
}
});
export default map;