You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Query data (automatically routed to correct shard, works with existing data!)
63
-
const result =awaitselectByPrimaryKey('existing-user-456', 'SELECT * FROM users WHERE id = ?', ['existing-user-456']);
63
+
const result =awaitfirst<User>('existing-user-456', 'SELECT * FROM users WHERE id = ?', ['existing-user-456']);
64
64
65
-
console.log(result.results[0]); // User data from existing database
65
+
console.log(result); // User data from existing database
66
66
```
67
67
68
-
## 🔄 Drop-in Replacement for Existing Databases
68
+
## Drop-in Replacement for Existing Databases
69
69
70
-
CollegeDB supports **seamless, automatic integration** with existing D1 databases that already contain data. Simply add your existing databases as shards in the configuration - CollegeDB will automatically detect existing data and create the necessary shard mappings **without requiring any manual migration steps**.
70
+
CollegeDB supports **seamless, automatic integration** with existing D1 databases that already contain data. Simply add your existing databases as shards in the configuration. CollegeDB will automatically detect existing data and create the necessary shard mappings **without requiring any manual migration steps**.
**That's it!** No migration scripts, no manual mapping creation, no downtime. Your existing data is immediately accessible through CollegeDB's sharding system.
@@ -169,7 +169,7 @@ if (result.success) {
169
169
After integration, initialize CollegeDB with your existing databases as shards:
170
170
171
171
```typescript
172
-
import { initialize } from'collegedb';
172
+
import { initialize, first } from'collegedb';
173
173
174
174
// Include existing databases as shards
175
175
initialize({
@@ -184,15 +184,15 @@ initialize({
184
184
});
185
185
186
186
// Existing data is now automatically routed!
187
-
const user =awaitselectByPrimaryKey('existing-user-123', 'SELECT * FROM users WHERE id = ?', ['existing-user-123']);
187
+
const user =awaitfirst('existing-user-123', 'SELECT * FROM users WHERE id = ?', ['existing-user-123']);
188
188
```
189
189
190
190
### Complete Drop-in Example
191
191
192
192
The simplest possible integration - just add your existing databases:
0 commit comments