drizzle-cube 0.1.2 → 0.1.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 +4 -65
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
|
|
5
5
|
Transform your Drizzle schema into a powerful, type-safe analytics platform with SQL injection protection and full TypeScript support.
|
|
6
6
|
|
|
7
|
+
> **⚠️ DEVELOPMENT WARNING**
|
|
8
|
+
> **This project is under active development and is not yet fully functional. I will update here when we reach an alpha/working version!**
|
|
9
|
+
> Feel free to star ⭐ the repo to stay updated on progress.
|
|
10
|
+
|
|
7
11
|
[](https://www.npmjs.com/package/drizzle-cube)
|
|
8
12
|
[](https://www.typescriptlang.org/)
|
|
9
13
|
[](https://orm.drizzle.team/)
|
|
@@ -240,56 +244,6 @@ Works with multiple frameworks via adapter pattern:
|
|
|
240
244
|
|
|
241
245
|
## Advanced Usage
|
|
242
246
|
|
|
243
|
-
### Complex Queries with CTEs
|
|
244
|
-
|
|
245
|
-
```typescript
|
|
246
|
-
import { sql } from 'drizzle-orm'
|
|
247
|
-
|
|
248
|
-
const advancedCube = defineCube('DepartmentAnalytics', {
|
|
249
|
-
title: 'Department Analytics',
|
|
250
|
-
|
|
251
|
-
// For complex queries, you can use raw SQL
|
|
252
|
-
sql: (ctx) => sql`
|
|
253
|
-
WITH department_stats AS (
|
|
254
|
-
SELECT
|
|
255
|
-
d.id,
|
|
256
|
-
d.name,
|
|
257
|
-
COUNT(e.id) as employee_count,
|
|
258
|
-
AVG(e.salary) as avg_salary
|
|
259
|
-
FROM ${schema.departments} d
|
|
260
|
-
LEFT JOIN ${schema.employees} e ON d.id = e.department_id
|
|
261
|
-
WHERE d.organisation_id = ${ctx.securityContext.organisationId}
|
|
262
|
-
GROUP BY d.id, d.name
|
|
263
|
-
)
|
|
264
|
-
SELECT * FROM department_stats
|
|
265
|
-
`,
|
|
266
|
-
|
|
267
|
-
dimensions: {
|
|
268
|
-
name: {
|
|
269
|
-
name: 'name',
|
|
270
|
-
title: 'Department Name',
|
|
271
|
-
sql: sql`name`,
|
|
272
|
-
type: 'string'
|
|
273
|
-
}
|
|
274
|
-
},
|
|
275
|
-
|
|
276
|
-
measures: {
|
|
277
|
-
employeeCount: {
|
|
278
|
-
name: 'employeeCount',
|
|
279
|
-
title: 'Employee Count',
|
|
280
|
-
sql: sql`employee_count`,
|
|
281
|
-
type: 'number'
|
|
282
|
-
},
|
|
283
|
-
avgSalary: {
|
|
284
|
-
name: 'avgSalary',
|
|
285
|
-
title: 'Average Salary',
|
|
286
|
-
sql: sql`avg_salary`,
|
|
287
|
-
type: 'number',
|
|
288
|
-
format: 'currency'
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
})
|
|
292
|
-
```
|
|
293
247
|
|
|
294
248
|
### Advanced Security with Row-Level Security
|
|
295
249
|
|
|
@@ -330,21 +284,6 @@ const secureCube = defineCube('SecureEmployees', {
|
|
|
330
284
|
})
|
|
331
285
|
```
|
|
332
286
|
|
|
333
|
-
### Multiple Database Support
|
|
334
|
-
|
|
335
|
-
```typescript
|
|
336
|
-
// PostgreSQL
|
|
337
|
-
import { drizzle } from 'drizzle-orm/postgres-js'
|
|
338
|
-
import postgres from 'postgres'
|
|
339
|
-
|
|
340
|
-
// MySQL
|
|
341
|
-
import { drizzle } from 'drizzle-orm/mysql2'
|
|
342
|
-
import mysql from 'mysql2/promise'
|
|
343
|
-
|
|
344
|
-
// SQLite
|
|
345
|
-
import { drizzle } from 'drizzle-orm/better-sqlite3'
|
|
346
|
-
import Database from 'better-sqlite3'
|
|
347
|
-
```
|
|
348
287
|
|
|
349
288
|
## API Reference
|
|
350
289
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "drizzle-cube",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Drizzle ORM-first semantic layer with Cube.js compatibility. Type-safe analytics and dashboards with SQL injection protection.",
|
|
5
5
|
"main": "./dist/server/index.js",
|
|
6
6
|
"types": "./dist/server/index.d.ts",
|