@frigear-nu/module-kit 0.0.2 → 0.0.3
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/README.md +16 -0
- package/dist/module.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,22 @@ extendDatabaseTable(nuxt, {
|
|
|
21
21
|
})
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
```ts
|
|
25
|
+
import { ColumnBuilderBase } from "drizzle-orm";
|
|
26
|
+
|
|
27
|
+
const defineUsersTable = (extras: Record<string, ColumnBuilderBase>) => {
|
|
28
|
+
return sqliteTable('users', {
|
|
29
|
+
id: serial('id').primaryKey(),
|
|
30
|
+
email: text('email').notNull().unique(),
|
|
31
|
+
password: text('password').notNull(),
|
|
32
|
+
createdAt: timestamp('created_at').defaultNow().notNull(),
|
|
33
|
+
updatedAt: timestamp('updated_at').defaultNow().notNull(),
|
|
34
|
+
...extras || {},
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
|
|
24
40
|
The schema file exports the named factory, which accepts an object of additional columns and returns a table. The factory must spread the received `extra` columns *last* in the object passed to the table builder (after every one of its own fields, including timestamps), so extended columns always end up last in the generated migration, matching the order they were registered in. Other modules can register column files during setup:
|
|
25
41
|
|
|
26
42
|
```ts
|
package/dist/module.json
CHANGED