orlandos-nl / MongoKitten

Native MongoDB driver for Swift, written in Swift

Home Page:https://orlandos.nl/docs/mongokitten/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Array with documents from collection

robert-joosen opened this issue · comments


    let collection       = db["users"]
    var projection: Projection = ["username","password"]

    projection.suppressIdentifier()

    var users: [Document] = Array(try collection.find("username" != nil, projecting: projection).flatMap{ document in
        return Document(array: document.arrayRepresentation)
    })

    let data: Document = [
       "data": Document(array: users)
    ]

    return data.makeExtendedJSONString()