Skip to content

Commit 38695bc

Browse files
author
CodeBuddy Attribution Bot
committed
fix(attribution): CloudBase JS SDK API 返回结构不清晰,导致文章创建后无法正确获取文档 ID (issue_mnpr3lei_r3vw5t)
1 parent df06c65 commit 38695bc

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

config/source/skills/no-sql-wx-mp-sdk/crud-operations.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ const result = await db.collection('todos').add({
1818
createdAt: new Date()
1919
});
2020

21-
console.log('Added document with ID:', result.id);
21+
console.log('Added document with ID:', result._id);
2222
```
2323

2424
**Return Value:**
2525
```javascript
2626
{
27-
id: "generated-doc-id", // Auto-generated document ID
27+
_id: "generated-doc-id", // Auto-generated document ID
2828
// ... other metadata
2929
}
3030
```
@@ -414,7 +414,7 @@ class TodoManager {
414414
createdAt: new Date(),
415415
updatedAt: new Date()
416416
});
417-
return result.id;
417+
return result._id;
418418
}
419419

420420
// Read (single)
@@ -500,7 +500,7 @@ async function safeCRUD() {
500500
title: 'New Todo'
501501
});
502502

503-
console.log('Created:', result.id);
503+
console.log('Created:', result._id);
504504

505505
} catch (error) {
506506
if (error.code === 'PERMISSION_DENIED') {
@@ -546,4 +546,3 @@ await db.runTransaction(async transaction => {
546546
8. **Limit updates**: Only update changed fields
547547
9. **Test permissions**: Ensure database security rules allow operations
548548
10. **Log operations**: Track important data changes
549-

0 commit comments

Comments
 (0)