@ff00ff/mammoth
Advanced tools
Comparing version 0.5.1 to 0.6.0
@@ -67,2 +67,9 @@ "use strict"; | ||
}()); | ||
var BinaryTest = /** @class */ (function () { | ||
function BinaryTest() { | ||
this.id = new columns_1.UuidColumn().primary().default(new keywords_1.UuidGenerateV4()); | ||
this.value = new columns_1.ByteaColumn().notNull(); | ||
} | ||
return BinaryTest; | ||
}()); | ||
var db = pool_1.createDatabase({ | ||
@@ -72,5 +79,43 @@ account: new Account(), | ||
foo: new Foo(), | ||
binaryTest: new BinaryTest(), | ||
}); | ||
describe('Query', function () { | ||
afterAll(function () { return db.destroy(); }); | ||
describe('bytea', function () { | ||
beforeEach(function () { return db.exec("CREATE TABLE binary_test (\n id UUID PRIMARY KEY NOT NULL DEFAULT uuid_generate_v4(),\n value BYTEA NOT NULL\n )"); }); | ||
afterEach(function () { return db.exec("DROP TABLE binary_test"); }); | ||
it("should create row", function () { return __awaiter(_this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, db | ||
.insertInto(db.binaryTest) | ||
.values({ | ||
id: null, | ||
value: new Buffer("this is a test :)"), | ||
})]; | ||
case 1: | ||
_a.sent(); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
it("should read from row", function () { return __awaiter(_this, void 0, void 0, function () { | ||
var rows; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, db.insertInto(db.binaryTest).values({ id: null, value: new Buffer("Hello, world!") })]; | ||
case 1: | ||
_a.sent(); | ||
return [4 /*yield*/, db.select(db.binaryTest.id, db.binaryTest.value).from(db.binaryTest)]; | ||
case 2: | ||
rows = _a.sent(); | ||
expect(rows).toEqual([{ | ||
id: rows[0].id, | ||
value: new Buffer("Hello, world!"), | ||
}]); | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }); | ||
}); | ||
describe('rows', function () { | ||
@@ -77,0 +122,0 @@ var ids = [uuid.v4(), uuid.v4(), uuid.v4()]; |
@@ -0,1 +1,2 @@ | ||
/// <reference types="node" /> | ||
import { Default, Keyword } from '../keywords'; | ||
@@ -156,1 +157,8 @@ import { PartialQuery } from '../query'; | ||
} | ||
export declare class ByteaColumn extends Column<Buffer> { | ||
dataType: string; | ||
} | ||
export declare class BlobColumn extends ByteaColumn { | ||
} | ||
export declare class BinaryColumn extends ByteaColumn { | ||
} |
@@ -442,2 +442,28 @@ "use strict"; | ||
exports.NumberColumn = NumberColumn; | ||
var ByteaColumn = /** @class */ (function (_super) { | ||
__extends(ByteaColumn, _super); | ||
function ByteaColumn() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
_this.dataType = 'BYTEA'; | ||
return _this; | ||
} | ||
return ByteaColumn; | ||
}(Column)); | ||
exports.ByteaColumn = ByteaColumn; | ||
var BlobColumn = /** @class */ (function (_super) { | ||
__extends(BlobColumn, _super); | ||
function BlobColumn() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BlobColumn; | ||
}(ByteaColumn)); | ||
exports.BlobColumn = BlobColumn; | ||
var BinaryColumn = /** @class */ (function (_super) { | ||
__extends(BinaryColumn, _super); | ||
function BinaryColumn() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
return BinaryColumn; | ||
}(ByteaColumn)); | ||
exports.BinaryColumn = BinaryColumn; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@ff00ff/mammoth", | ||
"version": "0.5.1", | ||
"version": "0.6.0", | ||
"main": "./lib/index.js", | ||
@@ -10,2 +10,12 @@ "types": "./lib/index.d.ts", | ||
}, | ||
"keywords": [ | ||
"typescript", | ||
"postgres", | ||
"query", | ||
"builder", | ||
"sql", | ||
"typed", | ||
"database", | ||
"orm" | ||
], | ||
"files": [ | ||
@@ -12,0 +22,0 @@ "lib", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
467069
7245