-
Notifications
You must be signed in to change notification settings - Fork 2
/
testdata.js
133 lines (131 loc) · 2.03 KB
/
testdata.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
var low = require('lowdb')
var db = low('./db.json')
var _ = require('lodash')
var data_customers = [
{
id: 1,
name: '林亮',
address: '北区宿舍 16-308',
region_id: 1
},
{
id: 2,
name: '何国辉',
address: '黎耀球楼 3楼',
region_id: 2
},
{
id: 3,
name: '刘兴林',
address: '黎耀球楼 2楼',
region_id: 2
}
]
var data_regions = [
{
id: 1,
name: '北区宿舍'
},
{
id: 2,
name: '黎耀球楼'
}
]
var data_products = [
{
id: 1,
name: '电脑'
},
{
id: 2,
name: '手机'
}
]
var data_orders = [
{
id: 1,
customer_id: 1,
order_date: '2015-05-11',
consign_date: '2015-05-13',
totalprice: 1000
},
{
id: 2,
customer_id: 2,
order_date: '2015-05-14',
consign_date: '2015-05-15',
totalprice: 3000
},
{
id: 3,
customer_id: 3,
order_date: '2015-05-15',
consign_date: '2015-05-15',
totalprice: 2000
},
{
id: 4,
customer_id: 2,
order_date: '2015-05-15',
consign_date: '2015-05-16',
totalprice: 4000
}
]
var data_orderspec = [
{
id: 1,
order_id: 1,
product_id: 1,
eachprice: 1000,
num: 1
},
{
id: 2,
order_id: 2,
product_id: 2,
eachprice: 3000,
num: 1
},
{
id: 3,
order_id: 3,
product_id: 1,
eachprice: 1000,
num: 2
},
{
id: 4,
order_id: 4,
product_id: 1,
eachprice: 1000,
num: 1
},
{
id: 5,
order_id: 4,
product_id: 2,
eachprice: 3000,
num: 1
}
]
db.object = {}
var db_customers = db('customers')
_.each(data_customers, function(item){
db_customers.push(item)
})
var db_regions = db('regions')
_.each(data_regions, function(item){
db_regions.push(item)
})
var db_products = db('products')
_.each(data_products, function(item){
db_products.push(item)
})
var db_orders = db('orders')
_.each(data_orders, function(item){
db_orders.push(item)
})
var db_orderspec = db('orderspec')
_.each(data_orderspec, function(item){
db_orderspec.push(item)
})