|
|
@@ -0,0 +1,50 @@
|
|
|
+'use strict'
|
|
|
+
|
|
|
+const faker = require('faker')
|
|
|
+
|
|
|
+const alarms = ['Normal', 'Alarm', 'Low Battery']
|
|
|
+
|
|
|
+function getEqumentData(ap_id) {
|
|
|
+ return {
|
|
|
+ ap_id,
|
|
|
+ aid_id: `輔具編號 ${faker.random.number(5)}`,
|
|
|
+ beacon_id: faker.hacker.noun() + faker.random.number({ min: 100, max: 999 }),
|
|
|
+ status: faker.random.number(3).toString(),
|
|
|
+ battery: faker.random.number(100),
|
|
|
+ alarm: alarms[faker.random.number(2)],
|
|
|
+ latitude: faker.address.latitude(),
|
|
|
+ longitude: faker.address.longitude(),
|
|
|
+ created_at: faker.date.recent(1)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+module.exports = {
|
|
|
+ up: (queryInterface, Sequelize) => {
|
|
|
+ return queryInterface.bulkInsert(
|
|
|
+ 'equipment_data',
|
|
|
+ Array.from(Array(20).keys()).map(() => getEqumentData('1'))
|
|
|
+ )
|
|
|
+
|
|
|
+ /*
|
|
|
+ Add altering commands here.
|
|
|
+ Return a promise to correctly handle asynchronicity.
|
|
|
+
|
|
|
+ Example:
|
|
|
+ return queryInterface.bulkInsert('People', [{
|
|
|
+ name: 'John Doe',
|
|
|
+ isBetaMember: false
|
|
|
+ }], {});
|
|
|
+ */
|
|
|
+ },
|
|
|
+
|
|
|
+ down: (queryInterface, Sequelize) => {
|
|
|
+ return queryInterface.bulkDelete('equipment_data', null, {})
|
|
|
+ /*
|
|
|
+ Add reverting commands here.
|
|
|
+ Return a promise to correctly handle asynchronicity.
|
|
|
+
|
|
|
+ Example:
|
|
|
+ return queryInterface.bulkDelete('People', null, {});
|
|
|
+ */
|
|
|
+ }
|
|
|
+}
|