@newcms/database 0.0.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/cache/index.d.ts +3 -0
- package/dist/cache/index.d.ts.map +1 -0
- package/dist/cache/index.js +2 -0
- package/dist/cache/index.js.map +1 -0
- package/dist/cache/object-cache.d.ts +139 -0
- package/dist/cache/object-cache.d.ts.map +1 -0
- package/dist/cache/object-cache.js +321 -0
- package/dist/cache/object-cache.js.map +1 -0
- package/dist/connection.d.ts +18 -0
- package/dist/connection.d.ts.map +1 -0
- package/dist/connection.js +32 -0
- package/dist/connection.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/repositories/options-repository.d.ts +59 -0
- package/dist/repositories/options-repository.d.ts.map +1 -0
- package/dist/repositories/options-repository.js +222 -0
- package/dist/repositories/options-repository.js.map +1 -0
- package/dist/schema/comments.d.ts +369 -0
- package/dist/schema/comments.d.ts.map +1 -0
- package/dist/schema/comments.js +47 -0
- package/dist/schema/comments.js.map +1 -0
- package/dist/schema/index.d.ts +9 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/index.js +9 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/links.d.ts +245 -0
- package/dist/schema/links.d.ts.map +1 -0
- package/dist/schema/links.js +17 -0
- package/dist/schema/links.js.map +1 -0
- package/dist/schema/options.d.ts +95 -0
- package/dist/schema/options.d.ts.map +1 -0
- package/dist/schema/options.js +12 -0
- package/dist/schema/options.js.map +1 -0
- package/dist/schema/posts.d.ts +509 -0
- package/dist/schema/posts.d.ts.map +1 -0
- package/dist/schema/posts.js +51 -0
- package/dist/schema/posts.js.map +1 -0
- package/dist/schema/scheduled-events.d.ts +156 -0
- package/dist/schema/scheduled-events.d.ts.map +1 -0
- package/dist/schema/scheduled-events.js +22 -0
- package/dist/schema/scheduled-events.js.map +1 -0
- package/dist/schema/sessions.d.ts +157 -0
- package/dist/schema/sessions.d.ts.map +1 -0
- package/dist/schema/sessions.js +26 -0
- package/dist/schema/sessions.js.map +1 -0
- package/dist/schema/terms.d.ts +343 -0
- package/dist/schema/terms.d.ts.map +1 -0
- package/dist/schema/terms.js +45 -0
- package/dist/schema/terms.js.map +1 -0
- package/dist/schema/users.d.ts +288 -0
- package/dist/schema/users.d.ts.map +1 -0
- package/dist/schema/users.js +30 -0
- package/dist/schema/users.js.map +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { eq } from 'drizzle-orm';
|
|
2
|
+
import { options } from '../schema/options.js';
|
|
3
|
+
const CACHE_GROUP = 'options';
|
|
4
|
+
const AUTOLOAD_CACHE_KEY = '__autoloaded';
|
|
5
|
+
const NOT_FOUND_GROUP = 'options_nf';
|
|
6
|
+
/**
|
|
7
|
+
* Options repository — CRUD for site options with integrated Redis cache.
|
|
8
|
+
*
|
|
9
|
+
* Behaviors per spec:
|
|
10
|
+
* - Options marked as autoload=true are pre-loaded into cache together
|
|
11
|
+
* - Cache of "not found" keys prevents repeated DB misses
|
|
12
|
+
* - Complex values (objects/arrays) stored as JSONB in addition to text
|
|
13
|
+
* - Write operations invalidate cache granularly
|
|
14
|
+
*/
|
|
15
|
+
export class OptionsRepository {
|
|
16
|
+
db;
|
|
17
|
+
cache;
|
|
18
|
+
constructor(db, cache) {
|
|
19
|
+
this.db = db;
|
|
20
|
+
this.cache = cache;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Get an option value.
|
|
24
|
+
*
|
|
25
|
+
* Lookup order:
|
|
26
|
+
* 1. Redis cache (group "options")
|
|
27
|
+
* 2. "Not found" cache (avoids repeated DB queries for missing keys)
|
|
28
|
+
* 3. Database
|
|
29
|
+
*/
|
|
30
|
+
async getOption(name, defaultValue) {
|
|
31
|
+
// 1. Check cache
|
|
32
|
+
const cached = await this.cache.get(name, CACHE_GROUP);
|
|
33
|
+
if (cached !== undefined)
|
|
34
|
+
return cached;
|
|
35
|
+
// 2. Check "not found" cache
|
|
36
|
+
const isNotFound = await this.cache.get(name, NOT_FOUND_GROUP);
|
|
37
|
+
if (isNotFound !== undefined)
|
|
38
|
+
return defaultValue;
|
|
39
|
+
// 3. Query database
|
|
40
|
+
const rows = await this.db
|
|
41
|
+
.select()
|
|
42
|
+
.from(options)
|
|
43
|
+
.where(eq(options.optionName, name))
|
|
44
|
+
.limit(1);
|
|
45
|
+
if (rows.length === 0) {
|
|
46
|
+
// Cache as "not found" to avoid future DB queries
|
|
47
|
+
await this.cache.set(name, true, NOT_FOUND_GROUP, 3600);
|
|
48
|
+
return defaultValue;
|
|
49
|
+
}
|
|
50
|
+
const row = rows[0];
|
|
51
|
+
const value = this.deserializeValue(row);
|
|
52
|
+
// Cache the value
|
|
53
|
+
await this.cache.set(name, value, CACHE_GROUP);
|
|
54
|
+
return value;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Add a new option. Fails if option already exists.
|
|
58
|
+
*
|
|
59
|
+
* @returns true if the option was created
|
|
60
|
+
*/
|
|
61
|
+
async addOption(name, value, autoload = true) {
|
|
62
|
+
// Check if already exists
|
|
63
|
+
const existing = await this.db
|
|
64
|
+
.select({ optionId: options.optionId })
|
|
65
|
+
.from(options)
|
|
66
|
+
.where(eq(options.optionName, name))
|
|
67
|
+
.limit(1);
|
|
68
|
+
if (existing.length > 0)
|
|
69
|
+
return false;
|
|
70
|
+
const { textValue, jsonValue } = this.serializeValue(value);
|
|
71
|
+
await this.db.insert(options).values({
|
|
72
|
+
optionName: name,
|
|
73
|
+
optionValue: textValue,
|
|
74
|
+
optionValueJson: jsonValue,
|
|
75
|
+
autoload,
|
|
76
|
+
});
|
|
77
|
+
// Update cache
|
|
78
|
+
await this.cache.set(name, value, CACHE_GROUP);
|
|
79
|
+
await this.cache.delete(name, NOT_FOUND_GROUP);
|
|
80
|
+
// Invalidate autoload cache if this is an autoloaded option
|
|
81
|
+
if (autoload) {
|
|
82
|
+
await this.cache.delete(AUTOLOAD_CACHE_KEY, CACHE_GROUP);
|
|
83
|
+
}
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Update an existing option, or create it if it doesn't exist.
|
|
88
|
+
*
|
|
89
|
+
* @returns true if the value was changed
|
|
90
|
+
*/
|
|
91
|
+
async updateOption(name, value, autoload) {
|
|
92
|
+
const { textValue, jsonValue } = this.serializeValue(value);
|
|
93
|
+
// Try to update
|
|
94
|
+
const existing = await this.db
|
|
95
|
+
.select()
|
|
96
|
+
.from(options)
|
|
97
|
+
.where(eq(options.optionName, name))
|
|
98
|
+
.limit(1);
|
|
99
|
+
if (existing.length === 0) {
|
|
100
|
+
// Option doesn't exist — create it
|
|
101
|
+
return this.addOption(name, value, autoload ?? true);
|
|
102
|
+
}
|
|
103
|
+
const row = existing[0];
|
|
104
|
+
// Check if value actually changed
|
|
105
|
+
if (row.optionValue === textValue && autoload === undefined) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
const updateData = {
|
|
109
|
+
optionValue: textValue,
|
|
110
|
+
optionValueJson: jsonValue,
|
|
111
|
+
};
|
|
112
|
+
if (autoload !== undefined) {
|
|
113
|
+
updateData['autoload'] = autoload;
|
|
114
|
+
}
|
|
115
|
+
await this.db
|
|
116
|
+
.update(options)
|
|
117
|
+
.set(updateData)
|
|
118
|
+
.where(eq(options.optionName, name));
|
|
119
|
+
// Update cache
|
|
120
|
+
await this.cache.set(name, value, CACHE_GROUP);
|
|
121
|
+
await this.cache.delete(name, NOT_FOUND_GROUP);
|
|
122
|
+
// Invalidate autoload cache
|
|
123
|
+
await this.cache.delete(AUTOLOAD_CACHE_KEY, CACHE_GROUP);
|
|
124
|
+
return true;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Delete an option.
|
|
128
|
+
*
|
|
129
|
+
* @returns true if the option existed and was deleted
|
|
130
|
+
*/
|
|
131
|
+
async deleteOption(name) {
|
|
132
|
+
const result = await this.db
|
|
133
|
+
.delete(options)
|
|
134
|
+
.where(eq(options.optionName, name))
|
|
135
|
+
.returning({ optionId: options.optionId });
|
|
136
|
+
if (result.length === 0)
|
|
137
|
+
return false;
|
|
138
|
+
// Remove from cache
|
|
139
|
+
await this.cache.delete(name, CACHE_GROUP);
|
|
140
|
+
await this.cache.delete(name, NOT_FOUND_GROUP);
|
|
141
|
+
await this.cache.delete(AUTOLOAD_CACHE_KEY, CACHE_GROUP);
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Load all autoloaded options into cache at once.
|
|
146
|
+
* Called during bootstrap to pre-warm the cache.
|
|
147
|
+
*/
|
|
148
|
+
async loadAutoloadedOptions() {
|
|
149
|
+
// Check if already loaded
|
|
150
|
+
const cached = await this.cache.get(AUTOLOAD_CACHE_KEY, CACHE_GROUP);
|
|
151
|
+
if (cached) {
|
|
152
|
+
const result = new Map(Object.entries(cached));
|
|
153
|
+
// Populate individual option caches
|
|
154
|
+
for (const [key, value] of result) {
|
|
155
|
+
await this.cache.set(key, value, CACHE_GROUP);
|
|
156
|
+
}
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
// Query all autoloaded options
|
|
160
|
+
const rows = await this.db
|
|
161
|
+
.select()
|
|
162
|
+
.from(options)
|
|
163
|
+
.where(eq(options.autoload, true));
|
|
164
|
+
const result = new Map();
|
|
165
|
+
const autoloadMap = {};
|
|
166
|
+
for (const row of rows) {
|
|
167
|
+
const value = this.deserializeValue(row);
|
|
168
|
+
result.set(row.optionName, value);
|
|
169
|
+
autoloadMap[row.optionName] = value;
|
|
170
|
+
await this.cache.set(row.optionName, value, CACHE_GROUP);
|
|
171
|
+
}
|
|
172
|
+
// Cache the complete autoload map
|
|
173
|
+
await this.cache.set(AUTOLOAD_CACHE_KEY, autoloadMap, CACHE_GROUP);
|
|
174
|
+
return result;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Serialize a value for storage.
|
|
178
|
+
* Complex types (objects, arrays) are stored in both text and JSONB columns.
|
|
179
|
+
*/
|
|
180
|
+
serializeValue(value) {
|
|
181
|
+
if (value === null || value === undefined) {
|
|
182
|
+
return { textValue: '', jsonValue: null };
|
|
183
|
+
}
|
|
184
|
+
if (typeof value === 'string') {
|
|
185
|
+
// Try to detect if it's JSON
|
|
186
|
+
try {
|
|
187
|
+
const parsed = JSON.parse(value);
|
|
188
|
+
if (typeof parsed === 'object' && parsed !== null) {
|
|
189
|
+
return { textValue: value, jsonValue: parsed };
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
// Not JSON, store as plain text
|
|
194
|
+
}
|
|
195
|
+
return { textValue: value, jsonValue: null };
|
|
196
|
+
}
|
|
197
|
+
if (typeof value === 'number' || typeof value === 'boolean') {
|
|
198
|
+
return { textValue: String(value), jsonValue: null };
|
|
199
|
+
}
|
|
200
|
+
// Objects and arrays → both text (JSON string) and JSONB
|
|
201
|
+
const textValue = JSON.stringify(value);
|
|
202
|
+
return { textValue, jsonValue: value };
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Deserialize a value from the database row.
|
|
206
|
+
* Prefers JSONB column when available (already parsed).
|
|
207
|
+
*/
|
|
208
|
+
deserializeValue(row) {
|
|
209
|
+
// Prefer JSONB if available
|
|
210
|
+
if (row.optionValueJson !== null && row.optionValueJson !== undefined) {
|
|
211
|
+
return row.optionValueJson;
|
|
212
|
+
}
|
|
213
|
+
// Try to parse as JSON
|
|
214
|
+
try {
|
|
215
|
+
return JSON.parse(row.optionValue);
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return row.optionValue;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
//# sourceMappingURL=options-repository.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-repository.js","sourceRoot":"","sources":["../../src/repositories/options-repository.ts"],"names":[],"mappings":"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C,KAAK,CAAC,CAAC;gBACjC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;oBACnD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;gBAChD,CAAC;YACF,CAAC;YAAC,MAAM,CAAC;gBACR,gCAAgC;YACjC,CAAC;YACD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC9C,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QACtD,CAAC;QAED,yDAAyD;QACzD,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;IACxC,CAAC;IAED;;;OAGG;IACK,gBAAgB,CAAI,GAG3B;QACA,4BAA4B;QAC5B,IAAI,GAAG,CAAC,eAAe,KAAK,IAAI,IAAI,GAAG,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;YACvE,OAAO,GAAG,CAAC,eAAoB,CAAC;QACjC,CAAC;QAED,uBAAuB;QACvB,IAAI,CAAC;YACJ,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,WAAW,CAAM,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACR,OAAO,GAAG,CAAC,WAAgB,CAAC;QAC7B,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
export declare const comments: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "comments";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
commentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "comment_id";
|
|
7
|
+
tableName: "comments";
|
|
8
|
+
dataType: "number";
|
|
9
|
+
columnType: "PgSerial";
|
|
10
|
+
data: number;
|
|
11
|
+
driverParam: number;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: true;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: undefined;
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
commentPostId: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "comment_post_id";
|
|
24
|
+
tableName: "comments";
|
|
25
|
+
dataType: "number";
|
|
26
|
+
columnType: "PgBigInt53";
|
|
27
|
+
data: number;
|
|
28
|
+
driverParam: string | number;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: true;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: undefined;
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
commentAuthor: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "comment_author";
|
|
41
|
+
tableName: "comments";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgText";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: true;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: [string, ...string[]];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
commentAuthorEmail: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "comment_author_email";
|
|
58
|
+
tableName: "comments";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "PgVarchar";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
notNull: true;
|
|
64
|
+
hasDefault: true;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: [string, ...string[]];
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {
|
|
73
|
+
length: 100;
|
|
74
|
+
}>;
|
|
75
|
+
commentAuthorUrl: import("drizzle-orm/pg-core").PgColumn<{
|
|
76
|
+
name: "comment_author_url";
|
|
77
|
+
tableName: "comments";
|
|
78
|
+
dataType: "string";
|
|
79
|
+
columnType: "PgVarchar";
|
|
80
|
+
data: string;
|
|
81
|
+
driverParam: string;
|
|
82
|
+
notNull: true;
|
|
83
|
+
hasDefault: true;
|
|
84
|
+
isPrimaryKey: false;
|
|
85
|
+
isAutoincrement: false;
|
|
86
|
+
hasRuntimeDefault: false;
|
|
87
|
+
enumValues: [string, ...string[]];
|
|
88
|
+
baseColumn: never;
|
|
89
|
+
identity: undefined;
|
|
90
|
+
generated: undefined;
|
|
91
|
+
}, {}, {
|
|
92
|
+
length: 200;
|
|
93
|
+
}>;
|
|
94
|
+
commentAuthorIp: import("drizzle-orm/pg-core").PgColumn<{
|
|
95
|
+
name: "comment_author_ip";
|
|
96
|
+
tableName: "comments";
|
|
97
|
+
dataType: "string";
|
|
98
|
+
columnType: "PgVarchar";
|
|
99
|
+
data: string;
|
|
100
|
+
driverParam: string;
|
|
101
|
+
notNull: true;
|
|
102
|
+
hasDefault: true;
|
|
103
|
+
isPrimaryKey: false;
|
|
104
|
+
isAutoincrement: false;
|
|
105
|
+
hasRuntimeDefault: false;
|
|
106
|
+
enumValues: [string, ...string[]];
|
|
107
|
+
baseColumn: never;
|
|
108
|
+
identity: undefined;
|
|
109
|
+
generated: undefined;
|
|
110
|
+
}, {}, {
|
|
111
|
+
length: 100;
|
|
112
|
+
}>;
|
|
113
|
+
commentDate: import("drizzle-orm/pg-core").PgColumn<{
|
|
114
|
+
name: "comment_date";
|
|
115
|
+
tableName: "comments";
|
|
116
|
+
dataType: "date";
|
|
117
|
+
columnType: "PgTimestamp";
|
|
118
|
+
data: Date;
|
|
119
|
+
driverParam: string;
|
|
120
|
+
notNull: true;
|
|
121
|
+
hasDefault: true;
|
|
122
|
+
isPrimaryKey: false;
|
|
123
|
+
isAutoincrement: false;
|
|
124
|
+
hasRuntimeDefault: false;
|
|
125
|
+
enumValues: undefined;
|
|
126
|
+
baseColumn: never;
|
|
127
|
+
identity: undefined;
|
|
128
|
+
generated: undefined;
|
|
129
|
+
}, {}, {}>;
|
|
130
|
+
commentDateGmt: import("drizzle-orm/pg-core").PgColumn<{
|
|
131
|
+
name: "comment_date_gmt";
|
|
132
|
+
tableName: "comments";
|
|
133
|
+
dataType: "date";
|
|
134
|
+
columnType: "PgTimestamp";
|
|
135
|
+
data: Date;
|
|
136
|
+
driverParam: string;
|
|
137
|
+
notNull: true;
|
|
138
|
+
hasDefault: true;
|
|
139
|
+
isPrimaryKey: false;
|
|
140
|
+
isAutoincrement: false;
|
|
141
|
+
hasRuntimeDefault: false;
|
|
142
|
+
enumValues: undefined;
|
|
143
|
+
baseColumn: never;
|
|
144
|
+
identity: undefined;
|
|
145
|
+
generated: undefined;
|
|
146
|
+
}, {}, {}>;
|
|
147
|
+
commentContent: import("drizzle-orm/pg-core").PgColumn<{
|
|
148
|
+
name: "comment_content";
|
|
149
|
+
tableName: "comments";
|
|
150
|
+
dataType: "string";
|
|
151
|
+
columnType: "PgText";
|
|
152
|
+
data: string;
|
|
153
|
+
driverParam: string;
|
|
154
|
+
notNull: true;
|
|
155
|
+
hasDefault: true;
|
|
156
|
+
isPrimaryKey: false;
|
|
157
|
+
isAutoincrement: false;
|
|
158
|
+
hasRuntimeDefault: false;
|
|
159
|
+
enumValues: [string, ...string[]];
|
|
160
|
+
baseColumn: never;
|
|
161
|
+
identity: undefined;
|
|
162
|
+
generated: undefined;
|
|
163
|
+
}, {}, {}>;
|
|
164
|
+
commentKarma: import("drizzle-orm/pg-core").PgColumn<{
|
|
165
|
+
name: "comment_karma";
|
|
166
|
+
tableName: "comments";
|
|
167
|
+
dataType: "number";
|
|
168
|
+
columnType: "PgBigInt53";
|
|
169
|
+
data: number;
|
|
170
|
+
driverParam: string | number;
|
|
171
|
+
notNull: true;
|
|
172
|
+
hasDefault: true;
|
|
173
|
+
isPrimaryKey: false;
|
|
174
|
+
isAutoincrement: false;
|
|
175
|
+
hasRuntimeDefault: false;
|
|
176
|
+
enumValues: undefined;
|
|
177
|
+
baseColumn: never;
|
|
178
|
+
identity: undefined;
|
|
179
|
+
generated: undefined;
|
|
180
|
+
}, {}, {}>;
|
|
181
|
+
commentApproved: import("drizzle-orm/pg-core").PgColumn<{
|
|
182
|
+
name: "comment_approved";
|
|
183
|
+
tableName: "comments";
|
|
184
|
+
dataType: "string";
|
|
185
|
+
columnType: "PgVarchar";
|
|
186
|
+
data: string;
|
|
187
|
+
driverParam: string;
|
|
188
|
+
notNull: true;
|
|
189
|
+
hasDefault: true;
|
|
190
|
+
isPrimaryKey: false;
|
|
191
|
+
isAutoincrement: false;
|
|
192
|
+
hasRuntimeDefault: false;
|
|
193
|
+
enumValues: [string, ...string[]];
|
|
194
|
+
baseColumn: never;
|
|
195
|
+
identity: undefined;
|
|
196
|
+
generated: undefined;
|
|
197
|
+
}, {}, {
|
|
198
|
+
length: 20;
|
|
199
|
+
}>;
|
|
200
|
+
commentAgent: import("drizzle-orm/pg-core").PgColumn<{
|
|
201
|
+
name: "comment_agent";
|
|
202
|
+
tableName: "comments";
|
|
203
|
+
dataType: "string";
|
|
204
|
+
columnType: "PgVarchar";
|
|
205
|
+
data: string;
|
|
206
|
+
driverParam: string;
|
|
207
|
+
notNull: true;
|
|
208
|
+
hasDefault: true;
|
|
209
|
+
isPrimaryKey: false;
|
|
210
|
+
isAutoincrement: false;
|
|
211
|
+
hasRuntimeDefault: false;
|
|
212
|
+
enumValues: [string, ...string[]];
|
|
213
|
+
baseColumn: never;
|
|
214
|
+
identity: undefined;
|
|
215
|
+
generated: undefined;
|
|
216
|
+
}, {}, {
|
|
217
|
+
length: 255;
|
|
218
|
+
}>;
|
|
219
|
+
commentType: import("drizzle-orm/pg-core").PgColumn<{
|
|
220
|
+
name: "comment_type";
|
|
221
|
+
tableName: "comments";
|
|
222
|
+
dataType: "string";
|
|
223
|
+
columnType: "PgVarchar";
|
|
224
|
+
data: string;
|
|
225
|
+
driverParam: string;
|
|
226
|
+
notNull: true;
|
|
227
|
+
hasDefault: true;
|
|
228
|
+
isPrimaryKey: false;
|
|
229
|
+
isAutoincrement: false;
|
|
230
|
+
hasRuntimeDefault: false;
|
|
231
|
+
enumValues: [string, ...string[]];
|
|
232
|
+
baseColumn: never;
|
|
233
|
+
identity: undefined;
|
|
234
|
+
generated: undefined;
|
|
235
|
+
}, {}, {
|
|
236
|
+
length: 20;
|
|
237
|
+
}>;
|
|
238
|
+
commentParent: import("drizzle-orm/pg-core").PgColumn<{
|
|
239
|
+
name: "comment_parent";
|
|
240
|
+
tableName: "comments";
|
|
241
|
+
dataType: "number";
|
|
242
|
+
columnType: "PgBigInt53";
|
|
243
|
+
data: number;
|
|
244
|
+
driverParam: string | number;
|
|
245
|
+
notNull: true;
|
|
246
|
+
hasDefault: true;
|
|
247
|
+
isPrimaryKey: false;
|
|
248
|
+
isAutoincrement: false;
|
|
249
|
+
hasRuntimeDefault: false;
|
|
250
|
+
enumValues: undefined;
|
|
251
|
+
baseColumn: never;
|
|
252
|
+
identity: undefined;
|
|
253
|
+
generated: undefined;
|
|
254
|
+
}, {}, {}>;
|
|
255
|
+
userId: import("drizzle-orm/pg-core").PgColumn<{
|
|
256
|
+
name: "user_id";
|
|
257
|
+
tableName: "comments";
|
|
258
|
+
dataType: "number";
|
|
259
|
+
columnType: "PgBigInt53";
|
|
260
|
+
data: number;
|
|
261
|
+
driverParam: string | number;
|
|
262
|
+
notNull: true;
|
|
263
|
+
hasDefault: true;
|
|
264
|
+
isPrimaryKey: false;
|
|
265
|
+
isAutoincrement: false;
|
|
266
|
+
hasRuntimeDefault: false;
|
|
267
|
+
enumValues: undefined;
|
|
268
|
+
baseColumn: never;
|
|
269
|
+
identity: undefined;
|
|
270
|
+
generated: undefined;
|
|
271
|
+
}, {}, {}>;
|
|
272
|
+
};
|
|
273
|
+
dialect: "pg";
|
|
274
|
+
}>;
|
|
275
|
+
export declare const commentmeta: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
276
|
+
name: "commentmeta";
|
|
277
|
+
schema: undefined;
|
|
278
|
+
columns: {
|
|
279
|
+
metaId: import("drizzle-orm/pg-core").PgColumn<{
|
|
280
|
+
name: "meta_id";
|
|
281
|
+
tableName: "commentmeta";
|
|
282
|
+
dataType: "number";
|
|
283
|
+
columnType: "PgSerial";
|
|
284
|
+
data: number;
|
|
285
|
+
driverParam: number;
|
|
286
|
+
notNull: true;
|
|
287
|
+
hasDefault: true;
|
|
288
|
+
isPrimaryKey: true;
|
|
289
|
+
isAutoincrement: false;
|
|
290
|
+
hasRuntimeDefault: false;
|
|
291
|
+
enumValues: undefined;
|
|
292
|
+
baseColumn: never;
|
|
293
|
+
identity: undefined;
|
|
294
|
+
generated: undefined;
|
|
295
|
+
}, {}, {}>;
|
|
296
|
+
commentId: import("drizzle-orm/pg-core").PgColumn<{
|
|
297
|
+
name: "comment_id";
|
|
298
|
+
tableName: "commentmeta";
|
|
299
|
+
dataType: "number";
|
|
300
|
+
columnType: "PgBigInt53";
|
|
301
|
+
data: number;
|
|
302
|
+
driverParam: string | number;
|
|
303
|
+
notNull: true;
|
|
304
|
+
hasDefault: false;
|
|
305
|
+
isPrimaryKey: false;
|
|
306
|
+
isAutoincrement: false;
|
|
307
|
+
hasRuntimeDefault: false;
|
|
308
|
+
enumValues: undefined;
|
|
309
|
+
baseColumn: never;
|
|
310
|
+
identity: undefined;
|
|
311
|
+
generated: undefined;
|
|
312
|
+
}, {}, {}>;
|
|
313
|
+
metaKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
314
|
+
name: "meta_key";
|
|
315
|
+
tableName: "commentmeta";
|
|
316
|
+
dataType: "string";
|
|
317
|
+
columnType: "PgVarchar";
|
|
318
|
+
data: string;
|
|
319
|
+
driverParam: string;
|
|
320
|
+
notNull: false;
|
|
321
|
+
hasDefault: false;
|
|
322
|
+
isPrimaryKey: false;
|
|
323
|
+
isAutoincrement: false;
|
|
324
|
+
hasRuntimeDefault: false;
|
|
325
|
+
enumValues: [string, ...string[]];
|
|
326
|
+
baseColumn: never;
|
|
327
|
+
identity: undefined;
|
|
328
|
+
generated: undefined;
|
|
329
|
+
}, {}, {
|
|
330
|
+
length: 255;
|
|
331
|
+
}>;
|
|
332
|
+
metaValue: import("drizzle-orm/pg-core").PgColumn<{
|
|
333
|
+
name: "meta_value";
|
|
334
|
+
tableName: "commentmeta";
|
|
335
|
+
dataType: "string";
|
|
336
|
+
columnType: "PgText";
|
|
337
|
+
data: string;
|
|
338
|
+
driverParam: string;
|
|
339
|
+
notNull: false;
|
|
340
|
+
hasDefault: false;
|
|
341
|
+
isPrimaryKey: false;
|
|
342
|
+
isAutoincrement: false;
|
|
343
|
+
hasRuntimeDefault: false;
|
|
344
|
+
enumValues: [string, ...string[]];
|
|
345
|
+
baseColumn: never;
|
|
346
|
+
identity: undefined;
|
|
347
|
+
generated: undefined;
|
|
348
|
+
}, {}, {}>;
|
|
349
|
+
metaValueJson: import("drizzle-orm/pg-core").PgColumn<{
|
|
350
|
+
name: "meta_value_json";
|
|
351
|
+
tableName: "commentmeta";
|
|
352
|
+
dataType: "json";
|
|
353
|
+
columnType: "PgJsonb";
|
|
354
|
+
data: unknown;
|
|
355
|
+
driverParam: unknown;
|
|
356
|
+
notNull: false;
|
|
357
|
+
hasDefault: false;
|
|
358
|
+
isPrimaryKey: false;
|
|
359
|
+
isAutoincrement: false;
|
|
360
|
+
hasRuntimeDefault: false;
|
|
361
|
+
enumValues: undefined;
|
|
362
|
+
baseColumn: never;
|
|
363
|
+
identity: undefined;
|
|
364
|
+
generated: undefined;
|
|
365
|
+
}, {}, {}>;
|
|
366
|
+
};
|
|
367
|
+
dialect: "pg";
|
|
368
|
+
}>;
|
|
369
|
+
//# sourceMappingURL=comments.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.d.ts","sourceRoot":"","sources":["../../src/schema/comments.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkCpB,CAAC;AAEF,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAevB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { pgTable, serial, bigint, text, timestamp, varchar, index, jsonb, } from 'drizzle-orm/pg-core';
|
|
2
|
+
import { posts } from './posts.js';
|
|
3
|
+
import { users } from './users.js';
|
|
4
|
+
export const comments = pgTable('comments', {
|
|
5
|
+
commentId: serial('comment_id').primaryKey(),
|
|
6
|
+
commentPostId: bigint('comment_post_id', { mode: 'number' })
|
|
7
|
+
.notNull()
|
|
8
|
+
.default(0)
|
|
9
|
+
.references(() => posts.id, { onDelete: 'cascade' }),
|
|
10
|
+
commentAuthor: text('comment_author').notNull().default(''),
|
|
11
|
+
commentAuthorEmail: varchar('comment_author_email', { length: 100 })
|
|
12
|
+
.notNull()
|
|
13
|
+
.default(''),
|
|
14
|
+
commentAuthorUrl: varchar('comment_author_url', { length: 200 }).notNull().default(''),
|
|
15
|
+
commentAuthorIp: varchar('comment_author_ip', { length: 100 }).notNull().default(''),
|
|
16
|
+
commentDate: timestamp('comment_date', { withTimezone: true }).notNull().defaultNow(),
|
|
17
|
+
commentDateGmt: timestamp('comment_date_gmt', { withTimezone: true }).notNull().defaultNow(),
|
|
18
|
+
commentContent: text('comment_content').notNull().default(''),
|
|
19
|
+
commentKarma: bigint('comment_karma', { mode: 'number' }).notNull().default(0),
|
|
20
|
+
commentApproved: varchar('comment_approved', { length: 20 }).notNull().default('1'),
|
|
21
|
+
commentAgent: varchar('comment_agent', { length: 255 }).notNull().default(''),
|
|
22
|
+
commentType: varchar('comment_type', { length: 20 }).notNull().default('comment'),
|
|
23
|
+
commentParent: bigint('comment_parent', { mode: 'number' }).notNull().default(0),
|
|
24
|
+
userId: bigint('user_id', { mode: 'number' })
|
|
25
|
+
.notNull()
|
|
26
|
+
.default(0)
|
|
27
|
+
.references(() => users.id),
|
|
28
|
+
}, (table) => [
|
|
29
|
+
index('idx_comment_post_id').on(table.commentPostId),
|
|
30
|
+
index('idx_comment_approved_date_gmt').on(table.commentApproved, table.commentDateGmt),
|
|
31
|
+
index('idx_comment_date_gmt').on(table.commentDateGmt),
|
|
32
|
+
index('idx_comment_parent').on(table.commentParent),
|
|
33
|
+
index('idx_comment_author_email').on(table.commentAuthorEmail),
|
|
34
|
+
]);
|
|
35
|
+
export const commentmeta = pgTable('commentmeta', {
|
|
36
|
+
metaId: serial('meta_id').primaryKey(),
|
|
37
|
+
commentId: bigint('comment_id', { mode: 'number' })
|
|
38
|
+
.notNull()
|
|
39
|
+
.references(() => comments.commentId, { onDelete: 'cascade' }),
|
|
40
|
+
metaKey: varchar('meta_key', { length: 255 }),
|
|
41
|
+
metaValue: text('meta_value'),
|
|
42
|
+
metaValueJson: jsonb('meta_value_json'),
|
|
43
|
+
}, (table) => [
|
|
44
|
+
index('idx_commentmeta_comment_id').on(table.commentId),
|
|
45
|
+
index('idx_commentmeta_meta_key').on(table.metaKey),
|
|
46
|
+
]);
|
|
47
|
+
//# sourceMappingURL=comments.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comments.js","sourceRoot":"","sources":["../../src/schema/comments.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,OAAO,EACP,MAAM,EACN,MAAM,EACN,IAAI,EACJ,SAAS,EACT,OAAO,EACP,KAAK,EACL,KAAK,GACL,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,MAAM,CAAC,MAAM,QAAQ,GAAG,OAAO,CAC9B,UAAU,EACV;IACC,SAAS,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,UAAU,EAAE;IAC5C,aAAa,EAAE,MAAM,CAAC,iBAAiB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;SAC1D,OAAO,EAAE;SACT,OAAO,CAAC,CAAC,CAAC;SACV,UAAU,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC;IACrD,aAAa,EAAE,IAAI,CAAC,gBAAgB,CAAC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC;IAC3D,kBAAkB,EAAE,OAAO,CAAC,sBAAsB,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC;SAClE,OAAO,EAAE;SACT,OAAO,CAAC,EAAE,CAAC;IACb,gBAAgB,EAAE,OAAO,CAAC,oBAAoB,EAAE,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,CAAC,KAAK,CAAC,OAAO,CAAC;CACnD,CACD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { posts, postmeta } from './posts.js';
|
|
2
|
+
export { users, usermeta } from './users.js';
|
|
3
|
+
export { comments, commentmeta } from './comments.js';
|
|
4
|
+
export { terms, termTaxonomy, termRelationships, termmeta } from './terms.js';
|
|
5
|
+
export { options } from './options.js';
|
|
6
|
+
export { links } from './links.js';
|
|
7
|
+
export { sessions } from './sessions.js';
|
|
8
|
+
export { scheduledEvents } from './scheduled-events.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schema/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
|