create-sip 1.4.4 → 1.4.6
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.
|
@@ -300,10 +300,24 @@ node op make/seeder employee
|
|
|
300
300
|
```javascript
|
|
301
301
|
|
|
302
302
|
async function up({context: QueryInterface}) {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
303
|
+
if(db.Employee) {
|
|
304
|
+
await db.Employee.bulkCreate([
|
|
305
|
+
{ id: 1, name: "John Smith" },
|
|
306
|
+
{ id: 2, name: "Alice Johnson" }
|
|
307
|
+
]);
|
|
308
|
+
}else {
|
|
309
|
+
const now = new Date()
|
|
310
|
+
await QueryInterface.bulkInsert('things', [
|
|
311
|
+
{
|
|
312
|
+
id: 1, name: "John Smith",
|
|
313
|
+
createdAt: now, updatedAt: now
|
|
314
|
+
},
|
|
315
|
+
{
|
|
316
|
+
id: 2, name: "Alice Johnson",
|
|
317
|
+
createdAt: now, updatedAt: now
|
|
318
|
+
}
|
|
319
|
+
]);
|
|
320
|
+
}
|
|
307
321
|
}
|
|
308
322
|
|
|
309
323
|
async function down({context: QueryInterface}) {
|
|
@@ -54,6 +54,9 @@ const ThingController = {
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
async tryStore(req, res) {
|
|
57
|
+
if(req.body.id) {
|
|
58
|
+
delete req.body.id
|
|
59
|
+
}
|
|
57
60
|
const thing = await Thing.create(req.body)
|
|
58
61
|
res.status(201)
|
|
59
62
|
res.json({
|
|
@@ -81,6 +84,9 @@ const ThingController = {
|
|
|
81
84
|
}
|
|
82
85
|
},
|
|
83
86
|
async tryUpdate(req, res) {
|
|
87
|
+
if(req.body.id) {
|
|
88
|
+
delete req.body.id
|
|
89
|
+
}
|
|
84
90
|
const recordNumber = await Thing.update(req.body, {
|
|
85
91
|
where: { id: req.params.id }
|
|
86
92
|
})
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import db from '../../app/models/modrels.js';
|
|
1
2
|
|
|
2
3
|
async function up({context: QueryInterface}) {
|
|
3
|
-
|
|
4
|
+
if(db.Employee) {
|
|
5
|
+
await db.Employee.bulkCreate([
|
|
6
|
+
|
|
7
|
+
]);
|
|
8
|
+
}else {
|
|
9
|
+
const now = new Date()
|
|
10
|
+
await QueryInterface.bulkInsert('things', [
|
|
4
11
|
|
|
5
|
-
|
|
12
|
+
]);
|
|
13
|
+
}
|
|
6
14
|
}
|
|
7
15
|
|
|
8
16
|
async function down({context: QueryInterface}) {
|