Skip to content

Commit d0d70dd

Browse files
Robin BuschmannRobin Buschmann
authored andcommitted
typo; markerIcon added
1 parent d36c1ef commit d0d70dd

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

migrations/20160913093713-alter-table-branding-add-imprint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ exports.up = function(db) {
2323

2424
exports.down = function(db) {
2525
return db.runSql(`
26-
ALTER TABLE Branding DROP COLUMN imprint;;
26+
ALTER TABLE Branding DROP COLUMN imprint;
2727
`);
2828
};
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use strict';
2+
3+
var dbm;
4+
var type;
5+
var seed;
6+
7+
/**
8+
* We receive the dbmigrate dependency from dbmigrate initially.
9+
* This enables us to not have to rely on NODE_PATH.
10+
*/
11+
exports.setup = function(options, seedLink) {
12+
dbm = options.dbmigrate;
13+
type = dbm.dataType;
14+
seed = seedLink;
15+
};
16+
17+
exports.up = function(db) {
18+
19+
return db.runSql(`
20+
ALTER TABLE Branding ADD markerIcon LONGBLOB;
21+
`);
22+
};
23+
24+
exports.down = function(db) {
25+
return db.runSql(`
26+
ALTER TABLE Branding DROP COLUMN markerIcon;
27+
`);
28+
};

models/Branding.ts

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,29 @@ export class Branding extends Model<Branding> {
2424

2525
@Column({
2626
type: DataType.BLOB,
27-
get() {
28-
const image = this.getDataValue('logoIcon');
29-
30-
if (image) {
31-
// convert buffer/blob data to image URL
32-
return image.toString('utf8');
33-
}
34-
}
27+
get: blobToImageUrlConverter('logoIcon')
3528
})
3629
logoIcon: string;
3730

31+
@Column({
32+
type: DataType.BLOB,
33+
get: blobToImageUrlConverter('markerIcon')
34+
})
35+
markerIcon: string;
36+
3837
@HasMany(() => Provider)
3938
providers: Provider[];
4039
}
40+
41+
function blobToImageUrlConverter(key: string) {
42+
43+
return function () {
44+
45+
const image = this.getDataValue(key);
46+
47+
if (image) {
48+
// convert buffer/blob data to image URL
49+
return image.toString('utf8');
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)