@blinkdotnew/sdk 0.14.10 → 0.14.11

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.
Files changed (2) hide show
  1. package/README.md +19 -14
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -35,8 +35,8 @@ const user = await blink.auth.me()
35
35
 
36
36
  // Database operations (zero config)
37
37
  const todos = await blink.db.todos.list({
38
- where: { user_id: user.id },
39
- orderBy: { created_at: 'desc' },
38
+ where: { userId: user.id },
39
+ orderBy: { createdAt: 'desc' },
40
40
  limit: 20
41
41
  })
42
42
 
@@ -205,6 +205,11 @@ The SDK now automatically converts between JavaScript camelCase and SQL snake_ca
205
205
  - **Stored as snake_case**: `user_id`, `created_at`, `is_completed`
206
206
  - **No manual conversion needed!**
207
207
 
208
+ **⚠️ Important: Always Use camelCase in Your Code**
209
+ - ✅ **Correct**: `{ userId: user.id, createdAt: new Date() }`
210
+ - ❌ **Wrong**: `{ user_id: user.id, created_at: new Date() }`
211
+ - **Exception**: Raw SQL queries still use snake_case (as stored in database)
212
+
208
213
  ```typescript
209
214
  // Create (ID auto-generated if not provided)
210
215
  const todo = await blink.db.todos.create({
@@ -230,23 +235,23 @@ const todos = await blink.db.todos.list({
230
235
 
231
236
  // Note: Boolean fields are returned as "0"/"1" strings from SQLite
232
237
  // Check boolean values using Number(value) > 0
233
- const completedTodos = todos.filter(todo => Number(todo.completed) > 0)
234
- const incompleteTodos = todos.filter(todo => Number(todo.completed) === 0)
238
+ const completedTodos = todos.filter(todo => Number(todo.isCompleted) > 0)
239
+ const incompleteTodos = todos.filter(todo => Number(todo.isCompleted) === 0)
235
240
 
236
241
  // Update
237
- await blink.db.todos.update(todo.id, { completed: true })
242
+ await blink.db.todos.update(todo.id, { isCompleted: true })
238
243
 
239
244
  // Delete
240
245
  await blink.db.todos.delete(todo.id)
241
246
 
242
247
  // Bulk operations (IDs auto-generated if not provided)
243
248
  await blink.db.todos.createMany([
244
- { title: 'Task 1', user_id: user.id }, // ID will be auto-generated
245
- { id: 'custom_id', title: 'Task 2', user_id: user.id } // Custom ID provided
249
+ { title: 'Task 1', userId: user.id }, // ID will be auto-generated
250
+ { id: 'custom_id', title: 'Task 2', userId: user.id } // Custom ID provided
246
251
  ])
247
252
  await blink.db.todos.upsertMany([...])
248
253
 
249
- // Raw SQL
254
+ // Raw SQL (note: raw SQL still uses snake_case as stored in database)
250
255
  const result = await blink.db.sql('SELECT * FROM todos WHERE user_id = ?', [user.id])
251
256
  ```
252
257
 
@@ -1209,9 +1214,9 @@ The SDK is written in TypeScript and provides full type safety:
1209
1214
  interface Todo {
1210
1215
  id: string
1211
1216
  title: string
1212
- completed: boolean // Will be returned as "0" or "1" string from SQLite
1213
- user_id: string
1214
- created_at: string
1217
+ isCompleted: boolean // Will be returned as "0" or "1" string from SQLite
1218
+ userId: string // Automatically converted from snake_case user_id
1219
+ createdAt: string // Automatically converted from snake_case created_at
1215
1220
  }
1216
1221
 
1217
1222
  // Note: Boolean fields are returned as "0"/"1" strings from SQLite
@@ -1219,12 +1224,12 @@ interface Todo {
1219
1224
  const todos = await blink.db.todos.list<Todo>()
1220
1225
 
1221
1226
  // Check boolean values properly
1222
- const completedTodos = todos.filter(todo => Number(todo.completed) > 0)
1223
- const incompleteTodos = todos.filter(todo => Number(todo.completed) === 0)
1227
+ const completedTodos = todos.filter(todo => Number(todo.isCompleted) > 0)
1228
+ const incompleteTodos = todos.filter(todo => Number(todo.isCompleted) === 0)
1224
1229
 
1225
1230
  // When filtering by boolean values in queries, use "0"/"1" strings
1226
1231
  const onlyCompleted = await blink.db.todos.list<Todo>({
1227
- where: { completed: "1" } // Use string "1" for true, "0" for false
1232
+ where: { isCompleted: "1" } // Use string "1" for true, "0" for false
1228
1233
  })
1229
1234
  // todos is fully typed as Todo[]
1230
1235
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blinkdotnew/sdk",
3
- "version": "0.14.10",
3
+ "version": "0.14.11",
4
4
  "description": "Blink TypeScript SDK for client-side applications - Zero-boilerplate CRUD + auth + AI + analytics + notifications for modern SaaS/AI apps",
5
5
  "keywords": [
6
6
  "blink",