@setupless/drizzle 0.1.0 → 0.1.1
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.
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/pg/id.d.ts +10 -0
- package/dist/cjs/pg/id.js +19 -0
- package/dist/cjs/pg/index.d.ts +1 -0
- package/dist/cjs/pg/index.js +5 -0
- package/dist/cjs/sqlite/id.d.ts +10 -0
- package/dist/cjs/sqlite/id.js +21 -0
- package/dist/cjs/sqlite/index.d.ts +1 -0
- package/dist/cjs/sqlite/index.js +5 -0
- package/package.json +26 -8
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"commonjs"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines an `id` primary-key column.
|
|
3
|
+
*
|
|
4
|
+
* PostgreSQL generates UUID values through the column's database default.
|
|
5
|
+
*/
|
|
6
|
+
export default function id(strategy?: "auto" | "uuid"): {
|
|
7
|
+
id: import("drizzle-orm").IsIdentity<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgIntegerBuilderInitial<"">>>, "always">;
|
|
8
|
+
} | {
|
|
9
|
+
id: import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/pg-core").PgUUIDBuilderInitial<"">>>>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = id;
|
|
4
|
+
const pg_core_1 = require("drizzle-orm/pg-core");
|
|
5
|
+
/**
|
|
6
|
+
* Defines an `id` primary-key column.
|
|
7
|
+
*
|
|
8
|
+
* PostgreSQL generates UUID values through the column's database default.
|
|
9
|
+
*/
|
|
10
|
+
function id(strategy = "auto") {
|
|
11
|
+
switch (strategy) {
|
|
12
|
+
case "auto":
|
|
13
|
+
return { id: (0, pg_core_1.integer)().primaryKey().generatedAlwaysAsIdentity() };
|
|
14
|
+
case "uuid":
|
|
15
|
+
return {
|
|
16
|
+
id: (0, pg_core_1.uuid)().primaryKey().defaultRandom(),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as id } from "./id.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines an `id` primary-key column.
|
|
3
|
+
*
|
|
4
|
+
* Drizzle generates UUID values in the application through `$defaultFn`.
|
|
5
|
+
*/
|
|
6
|
+
export default function id(strategy?: "auto" | "uuid"): {
|
|
7
|
+
id: import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").HasDefault<import("drizzle-orm").NotNull<import("drizzle-orm/sqlite-core").SQLiteIntegerBuilderInitial<"">>>>;
|
|
8
|
+
} | {
|
|
9
|
+
id: import("drizzle-orm").HasRuntimeDefault<import("drizzle-orm").HasDefault<import("drizzle-orm").IsPrimaryKey<import("drizzle-orm").NotNull<import("drizzle-orm/sqlite-core").SQLiteTextBuilderInitial<"", [string, ...string[]], undefined>>>>>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = id;
|
|
4
|
+
const sqlite_core_1 = require("drizzle-orm/sqlite-core");
|
|
5
|
+
/**
|
|
6
|
+
* Defines an `id` primary-key column.
|
|
7
|
+
*
|
|
8
|
+
* Drizzle generates UUID values in the application through `$defaultFn`.
|
|
9
|
+
*/
|
|
10
|
+
function id(strategy = "auto") {
|
|
11
|
+
switch (strategy) {
|
|
12
|
+
case "auto":
|
|
13
|
+
return { id: (0, sqlite_core_1.integer)().primaryKey({ autoIncrement: true }) };
|
|
14
|
+
case "uuid":
|
|
15
|
+
return {
|
|
16
|
+
id: (0, sqlite_core_1.text)()
|
|
17
|
+
.primaryKey()
|
|
18
|
+
.$defaultFn(() => crypto.randomUUID()),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as id } from "./id.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@setupless/drizzle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Small, typed helpers for defining Drizzle ORM schemas",
|
|
5
5
|
"homepage": "https://github.com/Setupless/drizzle#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -16,21 +16,39 @@
|
|
|
16
16
|
],
|
|
17
17
|
"type": "module",
|
|
18
18
|
"sideEffects": false,
|
|
19
|
-
"main": "./dist/index.js",
|
|
19
|
+
"main": "./dist/cjs/index.js",
|
|
20
20
|
"module": "./dist/index.js",
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
-
"
|
|
25
|
-
|
|
24
|
+
"import": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"require": {
|
|
29
|
+
"types": "./dist/cjs/index.d.ts",
|
|
30
|
+
"default": "./dist/cjs/index.js"
|
|
31
|
+
}
|
|
26
32
|
},
|
|
27
33
|
"./pg": {
|
|
28
|
-
"
|
|
29
|
-
|
|
34
|
+
"import": {
|
|
35
|
+
"types": "./dist/pg/index.d.ts",
|
|
36
|
+
"default": "./dist/pg/index.js"
|
|
37
|
+
},
|
|
38
|
+
"require": {
|
|
39
|
+
"types": "./dist/cjs/pg/index.d.ts",
|
|
40
|
+
"default": "./dist/cjs/pg/index.js"
|
|
41
|
+
}
|
|
30
42
|
},
|
|
31
43
|
"./sqlite": {
|
|
32
|
-
"
|
|
33
|
-
|
|
44
|
+
"import": {
|
|
45
|
+
"types": "./dist/sqlite/index.d.ts",
|
|
46
|
+
"default": "./dist/sqlite/index.js"
|
|
47
|
+
},
|
|
48
|
+
"require": {
|
|
49
|
+
"types": "./dist/cjs/sqlite/index.d.ts",
|
|
50
|
+
"default": "./dist/cjs/sqlite/index.js"
|
|
51
|
+
}
|
|
34
52
|
}
|
|
35
53
|
},
|
|
36
54
|
"publishConfig": {
|