Skip to content

Commit 8e3b675

Browse files
authored
feat(zmodel): add ulid() function (#1951)
1 parent 4d7275a commit 8e3b675

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

packages/schema/src/res/stdlib.zmodel

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function uuid(version: Int?): String {
9494
/**
9595
* Generates a globally unique identifier based on the CUID spec.
9696
*/
97-
function cuid(): String {
97+
function cuid(version: Int?): String {
9898
} @@@expressionContext([DefaultValue])
9999

100100
/**
@@ -103,6 +103,12 @@ function cuid(): String {
103103
function nanoid(length: Int?): String {
104104
} @@@expressionContext([DefaultValue])
105105

106+
/**
107+
* Generates an identifier based on the ulid spec.
108+
*/
109+
function ulid(): String {
110+
} @@@expressionContext([DefaultValue])
111+
106112
/**
107113
* Creates a sequence of integers in the underlying database and assign the incremented
108114
* values to the ID values of the created records based on the sequence.

packages/schema/tests/generator/prisma-generator.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ describe('Prisma generator test', () => {
164164
x String @default(nanoid())
165165
y String @default(dbgenerated("gen_random_uuid()"))
166166
z String @default(auth().id)
167+
cuid String @default(cuid())
168+
cuid2 String @default(cuid(2))
169+
ulid String @default(ulid())
167170
}
168171
`);
169172

@@ -183,6 +186,9 @@ describe('Prisma generator test', () => {
183186
expect(content).toContain('@default(nanoid())');
184187
expect(content).toContain('@default(dbgenerated("gen_random_uuid()"))');
185188
expect(content).not.toContain('@default(auth().id)');
189+
expect(content).toContain('@default(cuid())');
190+
expect(content).toContain('@default(cuid(2))');
191+
expect(content).toContain('@default(ulid())');
186192
});
187193

188194
it('triple slash comments', async () => {

0 commit comments

Comments
 (0)