Skip to content

Commit 6e84bcf

Browse files
committed
chore
1 parent d1ac01a commit 6e84bcf

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

lib/src/services/database_seeding_service.dart

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -80,30 +80,19 @@ class DatabaseSeedingService {
8080
final operations = <Map<String, Object>>[];
8181

8282
for (final item in fixtureData) {
83-
final id = getId(item);
84-
85-
if (!ObjectId.isValidHexId(id)) {
86-
_log.warning('Skipping document with invalid ID format: $id');
87-
continue;
88-
}
89-
90-
final objectId = ObjectId.fromHexString(id);
83+
// Generate a new ObjectId for each document
84+
final objectId = ObjectId();
9185
final document = toJson(item)..remove('id');
9286

9387
operations.add({
9488
'replaceOne': {
95-
'filter': {'_id': objectId},
89+
'filter': {}, // Match all documents (replace existing or insert new)
9690
'replacement': document,
9791
'upsert': true,
9892
},
9993
});
10094
}
10195

102-
if (operations.isEmpty) {
103-
_log.info('No valid documents to write for "$collectionName".');
104-
return;
105-
}
106-
10796
final result = await collection.bulkWrite(operations);
10897
_log.info(
10998
'Seeding for "$collectionName" complete. '

0 commit comments

Comments
 (0)