@@ -123,8 +123,8 @@ final class MongoDBPluginDriver: PluginDatabaseDriver {
123123 case . findOne:
124124 return 1
125125 case . aggregate( let collection, let pipeline) :
126- let docs = try await conn. aggregate ( database: db, collection: collection, pipeline: pipeline)
127- return docs. count
126+ let result = try await conn. aggregate ( database: db, collection: collection, pipeline: pipeline)
127+ return result . docs. count
128128 case . countDocuments( let collection, let filter) :
129129 let count = try await conn. countDocuments ( database: db, collection: collection, filter: filter)
130130 return Int ( count)
@@ -148,12 +148,12 @@ final class MongoDBPluginDriver: PluginDatabaseDriver {
148148 case . find( let collection, let filter, var options) :
149149 options. skip = offset
150150 options. limit = limit
151- let docs = try await conn. find (
151+ let result = try await conn. find (
152152 database: db, collection: collection, filter: filter,
153153 sort: options. sort, projection: options. projection,
154154 skip: offset, limit: limit
155155 )
156- return buildPluginResult ( from: docs, startTime: startTime)
156+ return buildPluginResult ( from: result . docs, startTime: startTime, isTruncated : result . isTruncated )
157157 default :
158158 return try await executeOperation ( operation, connection: conn, startTime: startTime)
159159 }
@@ -178,7 +178,7 @@ final class MongoDBPluginDriver: PluginDatabaseDriver {
178178 let docs = try await conn. find (
179179 database: currentDb, collection: table,
180180 filter: " {} " , sort: nil , projection: nil , skip: 0 , limit: 500
181- )
181+ ) . docs
182182
183183 if docs. isEmpty {
184184 return [
@@ -527,30 +527,29 @@ final class MongoDBPluginDriver: PluginDatabaseDriver {
527527
528528 switch operation {
529529 case . find( let collection, let filter, let options) :
530- let docs = try await conn. find (
530+ let result = try await conn. find (
531531 database: db, collection: collection, filter: filter,
532532 sort: options. sort, projection: options. projection,
533533 skip: options. skip ?? 0 , limit: options. limit ?? PluginRowLimits . defaultMax
534534 )
535- if docs. isEmpty {
535+ if result . docs. isEmpty {
536536 return PluginQueryResult (
537537 columns: [ " _id " ] , columnTypeNames: [ " ObjectId " ] ,
538538 rows: [ ] , rowsAffected: 0 , executionTime: Date ( ) . timeIntervalSince ( startTime)
539539 )
540540 }
541- let truncated = docs. count >= PluginRowLimits . defaultMax
542- return buildPluginResult ( from: docs, startTime: startTime, isTruncated: truncated)
541+ return buildPluginResult ( from: result. docs, startTime: startTime, isTruncated: result. isTruncated)
543542
544543 case . findOne( let collection, let filter) :
545- let docs = try await conn. find (
544+ let result = try await conn. find (
546545 database: db, collection: collection, filter: filter,
547546 sort: nil , projection: nil , skip: 0 , limit: 1
548547 )
549- return buildPluginResult ( from: docs, startTime: startTime)
548+ return buildPluginResult ( from: result . docs, startTime: startTime)
550549
551550 case . aggregate( let collection, let pipeline) :
552- let docs = try await conn. aggregate ( database: db, collection: collection, pipeline: pipeline)
553- return buildPluginResult ( from: docs, startTime: startTime)
551+ let result = try await conn. aggregate ( database: db, collection: collection, pipeline: pipeline)
552+ return buildPluginResult ( from: result . docs, startTime: startTime, isTruncated : result . isTruncated )
554553
555554 case . countDocuments( let collection, let filter) :
556555 let count = try await conn. countDocuments ( database: db, collection: collection, filter: filter)
0 commit comments