Skip to content

Commit 6f496cc

Browse files
committed
sequelize again
1 parent 0acd34a commit 6f496cc

File tree

2 files changed

+27
-15
lines changed

2 files changed

+27
-15
lines changed

rootfs_overlay/lkmc/nodejs/sequelize/update.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ await Inverses.create({value: 5, inverse: -5, name: 'five'});
3737
assert.strictEqual((await Inverses.findOne({ where: { value: 2 } })).inverse, -2);
3838
assert.strictEqual((await Inverses.findOne({ where: { value: 3 } })).inverse, -3);
3939
assert.strictEqual((await Inverses.findOne({ where: { value: 5 } })).inverse, -5);
40+
assert.strictEqual((await Inverses.findOne({ where: { value: 2 } })).name, 'two');
41+
assert.strictEqual((await Inverses.findOne({ where: { value: 3 } })).name, 'three');
42+
assert.strictEqual((await Inverses.findOne({ where: { value: 5 } })).name, 'five');
4043
assert.strictEqual(await Inverses.count(), 3);
4144

4245
// Update to fixed value.

rootfs_overlay/lkmc/nodejs/sequelize/updateOnDuplicate.js

100644100755
Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const sequelize = new Sequelize({
1313
});
1414

1515
(async () => {
16-
const IntegerNames = sequelize.define('IntegerNames',
16+
const Integer = sequelize.define('Integer',
1717
{
1818
value: {
1919
type: DataTypes.INTEGER,
@@ -23,24 +23,30 @@ const IntegerNames = sequelize.define('IntegerNames',
2323
name: {
2424
type: DataTypes.STRING,
2525
},
26+
inverse: {
27+
type: DataTypes.INTEGER,
28+
},
2629
},
2730
{
2831
timestamps: false,
2932
}
3033
);
31-
await IntegerNames.sync({force: true})
32-
await IntegerNames.create({value: 2, name: 'two'});
33-
await IntegerNames.create({value: 3, name: 'three'});
34-
await IntegerNames.create({value: 5, name: 'five'});
34+
await Integer.sync({force: true})
35+
await Integer.create({value: 2, inverse: -2, name: 'two'});
36+
await Integer.create({value: 3, inverse: -3, name: 'three'});
37+
await Integer.create({value: 5, inverse: -5, name: 'five'});
3538

3639
// Initial state.
37-
assert.strictEqual((await IntegerNames.findOne({ where: { value: 2 } })).name, 'two');
38-
assert.strictEqual((await IntegerNames.findOne({ where: { value: 3 } })).name, 'three');
39-
assert.strictEqual((await IntegerNames.findOne({ where: { value: 5 } })).name, 'five');
40-
assert.strictEqual(await IntegerNames.count(), 3);
40+
assert.strictEqual((await Integer.findOne({ where: { value: 2 } })).name, 'two');
41+
assert.strictEqual((await Integer.findOne({ where: { value: 3 } })).name, 'three');
42+
assert.strictEqual((await Integer.findOne({ where: { value: 5 } })).name, 'five');
43+
assert.strictEqual((await Integer.findOne({ where: { value: 2 } })).inverse, -2);
44+
assert.strictEqual((await Integer.findOne({ where: { value: 3 } })).inverse, -3);
45+
assert.strictEqual((await Integer.findOne({ where: { value: 5 } })).inverse, -5);
46+
assert.strictEqual(await Integer.count(), 3);
4147

4248
// Update.
43-
await IntegerNames.bulkCreate(
49+
await Integer.bulkCreate(
4450
[
4551
{value: 2, name: 'TWO'},
4652
{value: 3, name: 'THREE'},
@@ -50,11 +56,14 @@ await IntegerNames.bulkCreate(
5056
);
5157

5258
// Final state.
53-
assert.strictEqual((await IntegerNames.findOne({ where: { value: 2 } })).name, 'TWO');
54-
assert.strictEqual((await IntegerNames.findOne({ where: { value: 3 } })).name, 'THREE');
55-
assert.strictEqual((await IntegerNames.findOne({ where: { value: 5 } })).name, 'five');
56-
assert.strictEqual((await IntegerNames.findOne({ where: { value: 7 } })).name, 'SEVEN');
57-
assert.strictEqual(await IntegerNames.count(), 4);
59+
assert.strictEqual((await Integer.findOne({ where: { value: 2 } })).name, 'TWO');
60+
assert.strictEqual((await Integer.findOne({ where: { value: 3 } })).name, 'THREE');
61+
assert.strictEqual((await Integer.findOne({ where: { value: 5 } })).name, 'five');
62+
assert.strictEqual((await Integer.findOne({ where: { value: 7 } })).name, 'SEVEN');
63+
assert.strictEqual((await Integer.findOne({ where: { value: 2 } })).inverse, -2);
64+
assert.strictEqual((await Integer.findOne({ where: { value: 3 } })).inverse, -3);
65+
assert.strictEqual((await Integer.findOne({ where: { value: 5 } })).inverse, -5);
66+
assert.strictEqual(await Integer.count(), 4);
5867

5968
await sequelize.close();
6069
})();

0 commit comments

Comments
 (0)