Giter Club home page Giter Club logo

mongokitten's People

Contributors

andrewangeta avatar aymericio avatar bb441db avatar callo90 avatar coaoac avatar gabriellanata avatar guziq avatar gwynne avatar jaapwijnen avatar jhoogstraat avatar joachimm7 avatar joannis avatar justinm1 avatar lgaches avatar linus-hologram avatar loganwright avatar maciejpiotrowski89 avatar maksimorlovich avatar masterswift avatar obbut avatar paulrolfe avatar philmodin avatar readmecritic avatar robert-joosen avatar spirit-balanceholder avatar sujaykakkad avatar tayloraswift avatar the0xalex avatar tomlandrum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongokitten's Issues

Server initializer does not decode percent characters from mongodb:// url

I tried to pass a mongodb:// url with a password that contains an @ symbol like this one:

mongodb://joeshmo:password%[email protected]:27017

the server init is not decoding percent characted when extracting user and password from url

public convenience init(_ url: NSURL, using tcpDriver: MongoTCP.Type = Socks.TCPClient.self, automatically connecting: Bool = true) throws

Using removingPercentEncoding fixed my issue:

 if let user = url.user?.removingPercentEncoding, let pass = url.password?.removingPercentEncoding

2.0.0 roadmap

Must:

  • Proper SSL Support
  • 100% Documentation
  • Make final API breaking changes to clean up the code clarity
  • Fix MongoError messages for more clarity and context. Especially CommandFailure
  • Rename QueryProtocol
  • Return the amount of updated documents in update

API Changes:

  • Different methods for creating Projection Documents
  • Increase the amount of places where limitedBy and skipping can be used
  • Simple system for looking up references

Should:

  • Support MongoDB Roles
  • Complete Unit Tests

Could (not sure yet):

  • Simple model system

Build fails on snapshot 04-12

Hi,

the library doesn't install on the latest snapshot (04-12)

→ swift build
Cloning https://github.com/PlanTeam/MongoKitten.git
Resolved version: 0.5.12
Cloning https://github.com/cryptokitten/md5.git
Resolved version: 0.1.1
Cloning https://github.com/CryptoKitten/CryptoEssentials.git
Resolved version: 0.2.1
Cloning https://github.com/SwiftX/C7.git
Resolved version: 0.2.0
Cloning https://github.com/cryptokitten/scram.git
Resolved version: 0.3.2
Cloning https://github.com/CryptoKitten/PBKDF2.git
Resolved version: 0.3.1
Cloning https://github.com/CryptoKitten/HMAC.git
Resolved version: 0.3.1
Cloning https://github.com/CryptoKitten/SHA1.git
Resolved version: 0.3.2
Cloning https://github.com/planteam/bson.git
Resolved version: 1.2.7
Cloning https://github.com/qutheory/hummingbird.git
Resolved version: 1.1.2
Cloning https://github.com/ketzusaka/Strand
Resolved version: 1.1.0
Compiling Swift Module 'C7' (14 sources)
Compiling Swift Module 'Strand' (1 sources)
Compiling Swift Module 'BSON' (22 sources)
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/Strand-1.1.0/Sources/Strand.swift:29:38: error: nil cannot initialize specified type 'pthread_t' (aka 'UnsafeMutablePointer<_opaque_pthread_t>')
    private var pthread: pthread_t = nil
                                     ^
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/Strand-1.1.0/Sources/Strand.swift:40:30: error: cannot pass immutable value as inout argument: implicit conversion from 'pthread_t' to 'pthread_t?' requires a temporary
        guard pthread_create(&pthread, nil, runner, pointer) == 0 else { throw StrandError.threadCreationFailed }
                             ^~~~~~~~
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/Strand-1.1.0/Sources/Strand.swift:73:12: error: nil is incompatible with return type 'UnsafeMutablePointer<Void>' (aka 'UnsafeMutablePointer<()>')
    return nil
           ^
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/C7-0.2.0/Sources/AsyncStream.swift:4:18: warning: extraneous duplicate parameter name; 'length' already has an argument label
    func receive(length length: Int, result: (Void throws -> Data) -> Void)
                 ^~~~~~~

/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/C7-0.2.0/Sources/AsyncStream.swift:5:15: warning: extraneous duplicate parameter name; 'data' already has an argument label
    func send(data data: Data, result: (Void throws -> Void) -> Void)
              ^~~~~

/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/C7-0.2.0/Sources/Data.swift:34:26: error: method 'replaceSubrange(subRange:with:)' has different argument names from those required by protocol 'RangeReplaceableCollection' ('replaceSubrange(_:with:)')
    public mutating func replaceSubrange<C : Collection where C.Iterator.Element == Byte>(subRange: Range<Int>, with newElements: C) {
                         ^
                                                                                          _
Swift.RangeReplaceableCollection:16:26: note: requirement 'replaceSubrange(_:with:)' declared here
    public mutating func replaceSubrange<C : Collection where C.Iterator.Element == Iterator.Element>(_ subRange: Range<Self.Index>, with newElements: C)
                         ^
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/C7-0.2.0/Sources/Data.swift:34:26: error: method 'replaceSubrange(subRange:with:)' has different argument names from those required by protocol 'RangeReplaceableCollection' ('replaceSubrange(_:with:)')
    public mutating func replaceSubrange<C : Collection where C.Iterator.Element == Byte>(subRange: Range<Int>, with newElements: C) {
                         ^
                                                                                          _
Swift.RangeReplaceableCollection:16:26: note: requirement 'replaceSubrange(_:with:)' declared here
    public mutating func replaceSubrange<C : Collection where C.Iterator.Element == Iterator.Element>(_ subRange: Range<Self.Index>, with newElements: C)
                         ^
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/BSON-1.2.7/Sources/Document+SequenceType.swift:91:36: warning: extraneous duplicate parameter name; 'keepCapacity' already has an argument label
    public mutating func removeAll(keepCapacity keepCapacity: Bool = false) {
                                   ^~~~~~~~~~~~~

/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/BSON-1.2.7/Sources/Document+SequenceType.swift:34:33: error: missing argument label 'value:' in call
                self.updateValue(newValue, forKey: key)
                                ^
                                 value:
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/BSON-1.2.7/Sources/Document+SequenceType.swift:36:40: error: missing argument label 'key:' in call
                self.removeValueForKey(key)
                                       ^
                                       key:
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/BSON-1.2.7/Sources/Document+SequenceType.swift:64:47: error: missing argument label 'key:' in call
        guard let indexKey = self.indexForKey(key) else {
                                              ^
                                              key:
/Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/Packages/BSON-1.2.7/Sources/Document+SequenceType.swift:83:44: error: missing argument label 'key:' in call
        guard let index = self.indexForKey(key) else {
                                           ^
                                           key:
<unknown>:0: error: build had 3 command failures
error: exit(1): /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a.xctoolchain/usr/bin/swift-build-tool -f /Users/aevitas/Desktop/Coding/Swift/Server/league-downloader/.build/debug.yaml default

Any help will be appreciated.

build-error with swift 07-25

Hi,

i would like to build MongoKitten. Unfortunately even in an plane project i got following build output:

Cloning https://github.com/PlanTeam/MongoKitten.git
HEAD is now at 4df9cd0 Merge pull request #29 from LoganWright/patch-1
Resolved version: 1.4.1
Cloning https://github.com/CryptoKitten/MD5.git
HEAD is now at 3ac877d Newer CryptoEssentials
Resolved version: 0.10.0
Cloning https://github.com/CryptoKitten/CryptoEssentials.git
HEAD is now at 7165379 Merge pull request #12 from CryptoKitten/07-25
Resolved version: 0.10.0
Cloning https://github.com/CryptoKitten/SCRAM.git
HEAD is now at 5f3f89d Updated to 07-25
Resolved version: 0.10.0
Cloning https://github.com/CryptoKitten/PBKDF2.git
HEAD is now at 1c26567 Updated to 07-25
Resolved version: 0.10.0
Cloning https://github.com/CryptoKitten/HMAC.git
HEAD is now at a748975 Merge pull request #7 from CryptoKitten/07-25
Resolved version: 0.10.0
Cloning https://github.com/CryptoKitten/SHA1.git
HEAD is now at 2ea8e6c Merge pull request #5 from CryptoKitten/07-25
Resolved version: 0.10.0
Cloning https://github.com/OpenKitten/BSON.git
HEAD is now at 2c85f41 Fix for ISO8601DateFormatter change
Resolved version: 3.5.1
Cloning https://github.com/open-swift/C7.git
HEAD is now at ec599fb Updated to Swift 07-25 (#50)
Resolved version: 0.10.0
Cloning https://github.com/czechboy0/Socks.git
HEAD is now at 05154cb Updated to 07-25 (#67)
Resolved version: 0.10.0
Cloning https://github.com/ketzusaka/Strand.git
HEAD is now at 6278d10 Merge pull request #8 from ketzusaka/07-20
Resolved version: 1.6.0
Compile Swift Module 'SocksCore' (14 sources)
Compile Swift Module 'Strand' (1 sources)
Compile Swift Module 'C7' (23 sources)
Compile Swift Module 'CryptoEssentials' (15 sources)
Compile Swift Module 'BSON' (12 sources)
Compile Swift Module 'Socks' (5 sources)
Compile Swift Module 'SocksCoreExampleTCPServer' (1 sources)
Compile Swift Module 'SocksCoreExampleTCPClient' (1 sources)
Compile Swift Module 'SocksExampleUDPClient' (1 sources)
Compile Swift Module 'SocksExampleUDPServer' (1 sources)
Compile Swift Module 'SocksExampleTCPServer' (1 sources)
Compile Swift Module 'SocksExampleTCPClient' (1 sources)
Compile Swift Module 'SocksCoreExampleTCPKeepAliveServer' (1 sources)
Linking ./.build/debug/SocksCoreExampleTCPClient
Linking ./.build/debug/SocksCoreExampleTCPServer
Linking ./.build/debug/SocksExampleTCPClient
Linking ./.build/debug/SocksExampleUDPServer
Linking ./.build/debug/SocksExampleUDPClient
Linking ./.build/debug/SocksExampleTCPServer
Linking ./.build/debug/SocksCoreExampleTCPKeepAliveServer
Compile Swift Module 'SHA1' (1 sources)
Compile Swift Module 'HMAC' (1 sources)
Compile Swift Module 'MD5' (1 sources)
Compile Swift Module 'PBKDF2' (1 sources)
/Users/timkeiner/Projects/swift/vapor/test-mongo/Packages/BSON-3.5.1/Sources/ExtendedJSON.swift:405:36: error: initializer for conditional binding must have Optional type, not 'Date'
                                if let date = fmt.date(from: dateString) {
                                   ^
<unknown>:0: error: build had 1 command failures
error: exit(1): /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-07-25-a.xctoolchain/usr/bin/swift-build-tool -f /Users/timkeiner/Projects/swift/vapor/test-mongo/.build/debug.yaml

I build with the 07-25 Toolchain

 /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-07-25-a.xctoolchain/usr/bin/swift build

and had a clean project. With the following package.swift

import PackageDescription

let package = Package(
    name: "test-mongo",
    dependencies: [
      .Package(url: "https://github.com/PlanTeam/MongoKitten.git", majorVersion: 1, minor: 4)
    ]
)

OS X Version is: 10.11.16

Thanks in advance :)

cant connect mlab replicaset

this example is my problem
server = try Server("mongodb://heroku_xxxxx:[email protected]:23372,serveraddress-a1.mlab.com:23372/xxxxxxx?replicaSet=rs-xxxxxx", automatically: true)
thow error, MongoDB is not available on the given host and port Socket failed with code 61 ("No data available") [connectFailed] "Unknown error"

Segfault after switching from MongoKitten 1.1.0 to 1.2.0

After updating to MongoKitten 1.2.0 from MongoKitten 1.1.0 , we seem to have a regression bug for the 6/20 snapshot. Our project compiles as expected on El Capitan 10.11 with the xcode-beta 2 and the DEVELOPMENT-SNAPSHOT-2016-06-20-a only to immediately crash with a segmentation fault after running the executable.

Below is the stack trace for the error. From the trace frame #1 it fails in BSON/ExtendedJSON.swift calling ISO8601DateFormatter.

* thread #1: tid = 0xaa72, 0x00000001007384f8 libswiftCore.dylib`swift_getObjCClassMetadata + 24, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x20)
  * frame #0: 0x00000001007384f8 libswiftCore.dylib`swift_getObjCClassMetadata + 24
    frame #1: 0x000000010012278d TodoList`type metadata accessor for ISO8601DateFormatter + 45 at ExtendedJSON.swift:0
    frame #2: 0x0000000100122801 TodoList`___lldb_unnamed_symbol340$$TodoList + 17
    frame #3: 0x000000010073b601 libswiftCore.dylib`swift_getForeignTypeMetadata + 385
    frame #4: 0x000000010074568c libswiftCore.dylib`swift::TargetProtocolConformanceRecord<swift::InProcess>::getCanonicalTypeMetadata() const + 92
    frame #5: 0x0000000100745c28 libswiftCore.dylib`swift_conformsToProtocol + 792
    frame #6: 0x0000000100716acd libswiftCore.dylib`swift_dynamicCast + 605
    frame #7: 0x0000000100717ceb libswiftCore.dylib`_dynamicCastFromExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 91
    frame #8: 0x000000010071720d libswiftCore.dylib`swift_dynamicCast + 2461
    frame #9: 0x00000001000b153e TodoList`JSON.object.setter(newValue=0x00007fff5fbfe5e0, self=0x00007fff5fbfe6d0) + 350 at SwiftyJSON.swift:332
    frame #10: 0x00000001000b0689 TodoList`JSON.init(object=0x00007fff5fbfe6c8, self=SwiftyJSON.JSON @ 0x00007fff5fbfe6d0) -> JSON + 265 at SwiftyJSON.swift:118
    frame #11: 0x00000001000c77b9 TodoList`JSON.init(elements=0 values, self=SwiftyJSON.JSON @ 0x00007fff5fbfe8a0)]...) -> JSON + 505 at SwiftyJSON.swift:876
    frame #12: 0x00000001001c46f7 TodoList`static CloudFoundryEnv.(getAppEnv(options : JSON) throws -> AppEnv).(default argument 0) + 55 at CloudFoundryEnv.swift:24
    frame #13: 0x0000000100001d7a TodoList`main + 554 at main.swift:53
    frame #14: 0x00007fff8f90b5ad libdyld.dylib`start + 1
    frame #15: 0x00007fff8f90b5ad libdyld.dylib`start + 1

Documents array doesnt use Array<AnyObject( or other)>

when using Vapor framework that is best swift framework
query result [Document] that is array, but json engine cant convert this, it needs [AnyObject]. and Document object cant allow downcase [AnyObject].

I think Documents has return [AnyObject] option because for example i want to return all users list, i should loop in Object to convert Json engine valid type

ekran resmi 2016-10-13 16 54 04

Can't query nested array

I have a document of the following format.

{
    "_id" : ObjectId("17e2fb57247d5ef8cd6f4447"),
    "users" : [
        {
            "Name" : "Brad",
            "Age" : 42
        },
        {
            "Name" : "Paul",
            "Age" : 32
        }
    ]
}

There is no way to query the embedded array with Query builder. How would you find the record "Name" == "Brad"

Discuss triggers

In the near future, we should discuss our triggers implementation.

Argument labels '(_:, automatically:)' do not match any available overloads

Hi, following the tutorial:

dependencies: [ .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1, minor: 1), .Package(url: "https://github.com/OpenKitten/MongoKitten.git", majorVersion: 2, minor: 0) ]

Code:

import MongoKitten let server: Server server = try Server("mongodb://localhost:27017", automatically: true)

I am getting this error when building:

Compile Swift Module 'App' (3 sources) /Foo/Sources/App/main.swift:9:18: error: argument labels '(_:, automatically:)' do not match any available overloads server = try Server("mongodb://localhost:27017", automatically: true) ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Foo/Sources/App/main.swift:9:18: note: overloads for 'Server' exist with these partially matching parameter lists: (mongoURL: NSURL, using: MongoTCP.Type, automatically: Bool, maxConnecti ons: Int), (mongoURL: String, using: MongoTCP.Type, automatically: Bool, maxConnections: Int), (hostname: String, port: UInt16, authenticatedAs: (username: String, password: String, against: String)?, runningTcpDriver: MongoTCP .Type, automatically: Bool, maxConnections: Int) server = try Server("mongodb://localhost:27017", automatically: true)

Providing expected parameters is working of course:

server = try Server(mongoURL: "mongodb://localhost:27017", using: Socks.TCPClient.self, automatically: true, maxConnections: 5)

Question regarding arrays

Hi,

Great work on this project - my team has been playing with MongoKitten a fair amount of late, and have run into an issue that I'm hoping you can answer for us. Our version of Swift is:
3.0-PREVIEW-2 on Ubuntu 15.10.

I created a simple document for this test in Mongo. It is:

{
   "_id": ObjectId("57989a7e76ac858d418faf42"),
   "name": "Test",
   "vals": [ 1,2,3,4,5 ] 
}

If we print out the vals array, we end up with:
array(BSON.Document(storage: [60, 0, 0, 0, 1, 48, 0, 0, 0, 0, 0, 0, 0, 240, 63, 1, 49, 0, 0, 0, 0, 0, 0, 0, 0, 64, 1, 50, 0, 0, 0, 0, 0, 0, 0, 8, 64, 1, 51, 0, 0, 0, 0, 0, 0, 0, 16, 64, 1, 52, 0, 0, 0, 0, 0, 0, 0, 20, 64, 0], _count: nil))

This wasn't what we were expecting. We've tried to specify that the results were an Array, but this tosses an error. If we try and iterate over "vals" we end up with another error:

error: type 'Value' does not conform to protocol 'Sequence'

If we use doc["vals"][0] we end up with:
double(1.0)

Attempting to get .count on "vals" generates another error:

error: value of type 'Value' has no member 'count'

We're coming from the Ruby/Mongoid world. We're clearly missing something regarding Array processing with MongoKitten.

Thoughts?

Iterating over docs - super slow

I'm using 1.4.1 of MongoKitten.

I'm pulling back an entire collection (200 docs) and using Array() so that I preserve the cursor contents after iterating over them. Each document has about 150 fields, most of which are integer and float values. Some documents have embedded documents (max 5) that are versions of the main document.

Just iterating over the entire collection, and printing something simple like "doc found" runs incredibly fast. As soon as I test each doc for a condition, I end up with the process taking an extremely long time. Each iteration is taking about 5 seconds.

This is super slow:

for doc in allDocs {
    if doc["enabled"].stringValue == "yes" {
        print("System \(doc["nickname"]) is enabled")
    }
}

This is almost instantaneous:

for doc in allDocs {
    print("doc found")
}

Problem connecting to localhost

I can't seem to be able to figure this out ...
Every time I use the simple sample code connecting to localhost I get

"MongoDB is not available on the given host and port (Socket failed with code 61 ("No data available") [connectFailed] "Unknown error")."

There are no issues when I connect to mLab.
Why could this be? Mongo is running locally and if I connect in a second terminal with the 'mongo' command everything works fine. I connect to "mongodb://localhost", have tried adding the correct port too, but no luck!

Can't run project with MongoKitten package

I'lll preface this with the fact that I'm still figuring out SPM. I'm trying to check MongoKitten but can't get it to run. A simple print("test") in main crashes with a BAD_ACCESS.

Just curious if you have any insight if there is something in the lib that could be interfering. If I swap out MongoKitten for another package, update, and build; everything will run.

As for details I am using 1.3.0 and Swift Preview-2, also tried with older builds and the 6-20 snapshot.

Hope you can help get this sorted so I can see if it will work for me.

A question about the `_id == .null`,

when create a new document, only the _id == .noting been handled

if input["_id"] == .nothing {
    var output = input
    output["_id"] = ~ObjectId()
    newDocuments.append(output)
    return .document(output)

question is the _id == .null should be covered, or just handle this in my own program?

Full support for MongoDB Database Commands

Administration Commands:

  • Drop database
  • Create collection
  • Clone collection
  • Create index
  • List indexes
  • Drop index
  • Create user
  • Update user
  • Drop user
  • Drop all users
  • Grant role to user
  • Revoke role from user
  • Get user info
  • Create role
  • Update role
  • Drop role
  • Drop all roles
  • Grant role

Correct error handling

Currently we throw an "InternalInconsistency" error in almost every place where we're not sure what to feed back.
We need to build in support for proper MongoDB errors and return them in a "swifty" way.

Also we need to get rid of any and all "abort()" and other crashing statements.

Installation problems

Hello,

My name is Marlon.

I am a software developper, but I am not used to systems like GitHub.

I am interested in your project but couldn't find any other way to talk to you other than openning an issue.

If I should contact you by another way, please let me know.

I have tried to install the mongoKitten library on my Mac (late 2013, Macbook Air, mac OS 10.11.5, Xcode 7.3.1 ) but couldn't make it work.

I followed your documentation.

The requirements are:

• A MongoDB server : do I need to have a mongoDB server on my machine? Because I have an instance running somehwere else and was planning to use it. Any way I tried it with and without mongo installed and got the same results. - checked
• Some basic knowledge of MongoDB or time to research about MongoDB - checked
• The swift version described in  .swift-version , see
swiftenv. - I did try innstalling mongoKitten with and without swiftenv installed. When I installed swiftEnv, I set it to swift 2.2 and also used the system version and got no results.- Checked.

As I have xcode 7.3.1, I am assuming for me the install setup should be using swift 2.2. I then installed carthage and created a cartfile with

github "OpenKitten/MongoKitten" ~> 1.1

Then I issued carthage update and carthage downloaded mongoKitten 1.5

But after downloading, nothing happened. The folder with sources was downloaded but the build folder is empty. Carthage pointed a xcodebuild log, but the file is empty.

No other logs, no errors on the terminal shown during carthage update, nothing else.

I am assuming either that there is some dependency that I happen not to have or that my system is lacking something but I have no idea about what it would be.

Can you help me?

Sorting in find seems to be ignored

The "sortedBy" parameter seems to be ignored in findOne. The query itself is working and returning data, but always the the first in the database. Quering the database from the shell gives the correct result:

db.data.find({userToken: "ztJTb5kmODfBcbP-Em7n"}).sort({date: -1}).limit(1)

My code basically looks like:

let sortDocument: Document = ["date": -1]
let latestData = try dataCollection.findOne(matching: "userToken" == "ztJTb5kmODfBcbP-Em7n", sortedBy: sortDocument, projecting: nil, skipping: nil)

Failed to compile

Package.swift

import PackageDescription

let package = Package(
    name: "daemon",
    dependencies: [
        .Package(url: "https://github.com/vapor/vapor.git", majorVersion: 1),
        .Package(url: "https://github.com/OpenKitten/MongoKitten.git", majorVersion: 2)
    ],
    exclude: [
        "Config",
        "Database",
        "Localization",
        "Public",
        "Resources",
        "Tests",
    ]
)

I'm trying to build template project which vapor generates. The only change I'm doing is adding dependency to beta MongoKitten. With this dependency it fails to build on Ubuntu.
Compiler fails with the following error:

/whatever/daemon/Packages/CryptoKitten-0.0.0/Sources/Cryptography/SHA1/SHA1.swift:200:18: error: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions
        hashCode = [
        ~~~~~~~~~^~~

Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-38-generic x86_64)
Vapor Toolbox v1.0.3
Swift version 3.0-dev (LLVM b9bd56d1b8, Clang 23f1b289cf, Swift edd2ecdf0c)
Target: x86_64-unknown-linux-gnu

swift build command fails with syntax error

Hi There!

I'm having trouble building MongoKitten via swift build, when I run the command, I get a bunch of errors similar to the following, all appearing to come from code in MongoCryptoEssentials.

/Users/Harry/Documents/Code/Libraries/MongoKitten/Sources/MongoCryptoEssentials/BlockMode.swift:21:71: error: @escaping attribute only applies to function types
    static func makeEncryptionIterator(iv: [UInt8], cipherOperation: @escaping CipherBlockOperation, inputGenerator: AnyIterator<[UInt8]>) -> AnyIterator<[UInt8]>

As far as I can tell, I'm executing the proper version of Swift:

swiftenv which swift
/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-08-18-a.xctoolchain/usr/bin/swift

Have you run into this problem before? Am I doing something wrong?

Unable to build on Heroku

I'm getting several errors related to threading when building on Heroku which is Ubuntu 14.1 I believe:

remote: /tmp/build_aededebadd4c4d1e6daca762e1f8b226/Packages/MongoKitten-0.2.1/Sources/Server.swift:45:35: error: use of unresolved identifier 'dispatch_get_global_queue'
remote:     private let backgroundQueue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)
remote:                                   ^~~~~~~~~~~~~~~~~~~~~~~~~
remote: /tmp/build_aededebadd4c4d1e6daca762e1f8b226/Packages/MongoKitten-0.2.1/Sources/Server.swift:45:61: error: use of unresolved identifier 'QOS_CLASS_BACKGROUND'
remote:     private let backgroundQueue = dispatch_get_global_queue(QOS_CLASS_BACKGROUND, 0)
remote:                                                             ^~~~~~~~~~~~~~~~~~~~
remote: /tmp/build_aededebadd4c4d1e6daca762e1f8b226/Packages/MongoKitten-0.2.1/Sources/Server.swift:81:9: error: use of unresolved identifier 'dispatch_async'
remote:         dispatch_async(backgroundQueue, backgroundLoop)
remote:         ^~~~~~~~~~~~~~
remote: /tmp/build_aededebadd4c4d1e6daca762e1f8b226/Packages/MongoKitten-0.2.1/Sources/Server.swift:104:9: error: use of unresolved identifier 'dispatch_async'
remote:         dispatch_async(backgroundQueue, backgroundLoop)
remote:         ^~~~~~~~~~~~~~

Really looking forward to this library, let me know if I can help resolve this issue.

Using: Development Snapshot 2016-03-01-a

Failed to compile Ubuntu 16.04

/Packages/MongoKitten-1.7.1/Sources/MongoKitten/GridFS.swift:161:41: error: cannot convert value of type 'Int64' to expected dictionary value type 'Value'
"n": ~Int64(n),
^~~~~~~~~
Value( )

MongoKitten fails to compile on ubuntu 16.04

No such module BSON in QueryBuilder.swift

I was having issues using the Swift package manager it would cause my Xcode to crash.

So I added the .swift files for MongoKitten directly into my project and it seems to work fine but I can't compile it because I get an error on the import BSON statement saying no such modules exists.

How do I fix this?

Query Builder doesn't work with ISODate

MongoDB Collection has field scheduledDepartureTime which is stored as ISODate in DB

/* 1 */
{
    "scheduledDepartureTime" : ISODate("2016-10-02T18:30:00.000Z"),
}

/* 2 */
{
    "scheduledDepartureTime" : ISODate("2016-10-03T18:30:00.000Z"),
}

/* 3 */
{
    "scheduledDepartureTime" : ISODate("2016-10-04T18:30:00.000Z"),
}

Swift Code Snippet:

let q: Query = "scheduledDepartureTime" >= "2016-10-01T18:30:00.000Z"
print("Q: \(q)")

let result = try self.collection.find(matching: q)
print("Result: \(result)")

Output:
The result returned from DB is nil.

Q: Query(aqt: MongoKitten.AQT.greaterThanOrEqual("scheduledDepartureTime", BSON.Value.string("2016-10-01T18:30:00.000Z")))
Result: []

Cannot create dynamic Document for arrays and nested jsons

var username = "mongo"
var array = [1,2,3,4]
var dict = ["name": "kitten", "type": "cat"]

let userCollection = database["users"]

let userDocument: Document = [
            "username":  .string(username),
            "array": .array(arr),
            "dictionary": .array(dict),
        ]

try userCollection.insert(userDocument)
error: cannot convert value of type '[Int]' to expected argument type 'Document'
              array: .array(array),
                            ^~~~~

Why do you need Document type and why can't we create it dynamically?

Please provide JSON or Dictionary datatype support for queries in mongodb or atleast provide raw query support so that we can use raw strings to query mongo database

Compile Error on Download + Clean Build with Xcode 8.1

  1. With Xcode 8.1
  2. Download latest master
  3. Build MongoKitten

Expected -
Builds.

Actual -
Two compiler errors (see attached).

Error text: /MongoKitten-master 2/Sources/MongoKitten/Cursor.swift:70:32: Cannot convert value of type 'Int64' to expected dictionary value type 'Value'

screen shot 2016-10-25 at 11 29 08 pm

Compiling into a static library

Hi,

so I am trying to compile this into a static library, because I need to use SwiftyJSON, which currently doesn't support Swift3. For that purpose I would like to create a MongoKitten.a static library that I can then add to my project.
However when compiling PBKDF2 (I'm guessing) throws me this error.

→ swift build --configuration release
Compiling Strand
Compiling BSON
Compiling CryptoEssentials
Compiling MD5
Compiling HMAC
Compiling SHA1
Compiling PBKDF2
Assertion failed: (onlyHaveDebugUses(&I) && "Cannot erase instruction that is used!"), function eraseInstFromFunction, file /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/SILOptimizer/SILCombiner/SILCombine.cpp, line 292.
0  swift                    0x00000001098117eb llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift                    0x0000000109810a76 llvm::sys::RunSignalHandlers() + 70
2  swift                    0x0000000109811ebf SignalHandler(int) + 383
3  libsystem_platform.dylib 0x00007fff8a7c652a _sigtramp + 26
4  libsystem_platform.dylib 0x00007fff647f09a5 _sigtramp + 3657606293
5  swift                    0x0000000109811c96 abort + 22
6  swift                    0x0000000109811c71 __assert_rtn + 81
7  swift                    0x0000000107015141 swift::SILCombiner::eraseInstFromFunction(swift::SILInstruction&, llvm::ilist_iterator<swift::SILInstruction>&, bool) + 977
8  swift                    0x0000000107023d6d swift::SILCombiner::visitAllocStackInst(swift::AllocStackInst*) + 1741
9  swift                    0x000000010701591b swift::SILCombiner::doOneIteration(swift::SILFunction&, unsigned int) + 1723
10 swift                    0x000000010701656a (anonymous namespace)::SILCombine::run() + 234
11 swift                    0x000000010707eeff swift::SILPassManager::runPassesOnFunction(llvm::ArrayRef<swift::SILFunctionTransform*>, swift::SILFunction*, bool) + 1919
12 swift                    0x0000000107080019 swift::SILPassManager::runFunctionPasses(llvm::ArrayRef<swift::SILFunctionTransform*>) + 1193
13 swift                    0x00000001070810c4 swift::SILPassManager::runOneIteration() + 964
14 swift                    0x000000010708b4b7 swift::runSILOptimizationPasses(swift::SILModule&) + 231
15 swift                    0x0000000106c79e90 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 14128
16 swift                    0x0000000106c758af frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2879
17 swift                    0x0000000106c70dad main + 2637
18 libdyld.dylib            0x00007fff9a1fc5ad start + 1
Stack dump:
0.  Program arguments: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a.xctoolchain/usr/bin/swift -frontend -c /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Document+LiteralConvertibles.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Document+Operators.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Document+SequenceType.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Document+Serialization.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Document.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Element.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Error.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Helpers.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/ObjectId.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Value+Comparing.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Value+Extraction.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Value+LiteralConvertibles.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Value+Serialization.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Value+Subscript.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/Value.swift /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/Packages/BSON-0.0.0/Sources/ValueConvertible.swift -target x86_64-apple-macosx10.10 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -I /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/.build/release -D SWIFT_PACKAGE -emit-module-doc-path /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/.build/release/BSON.swiftdoc -O -parse-as-library -module-name BSON -emit-module-path /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/.build/release/BSON.swiftmodule -o /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/.build/release/BSON.o
1.  While running SILFunctionTransform "SIL Combine" on SILFunction "@_TFV4BSON8DocumentCfzT4dataGSaVs5UInt8_13consumedBytesRSi_S0_".
<unknown>:0: error: build had 1 command failures
error: exit(1): /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2016-04-12-a.xctoolchain/usr/bin/swift-build-tool -f /Users/aevitas/Desktop/Coding/Swift/Server/MongoKitten/.build/release.yaml default

Also, how come that there is no .a file being generated in the debug mode?

fatal error: unexpectedly found nil while unwrapping an Optional value

Hi, I'm experiencing this issue:

fatal error: unexpectedly found nil while unwrapping an Optional value
Current stack trace:
/root/swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a-ubuntu15.10/usr/lib/swift/linux/libswiftCore.so(swift_reportError+0x8b) [0x7ffff7b4b7db]
/root/swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a-ubuntu15.10/usr/lib/swift/linux/libswiftCore.so(_swift_stdlib_reportFatalError+0x3d) [0x7ffff7b5ca1d]
/root/swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a-ubuntu15.10/usr/lib/swift/linux/libswiftCore.so(+0x2635cf) [0x7ffff7b095cf]
/root/swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a-ubuntu15.10/usr/lib/swift/linux/libswiftCore.so(+0x133c1f) [0x7ffff79d9c1f]
/root/swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a-ubuntu15.10/usr/lib/swift/linux/libswiftCore.so(+0x23dffe) [0x7ffff7ae3ffe]
/root/swift-DEVELOPMENT-SNAPSHOT-2016-04-25-a-ubuntu15.10/usr/lib/swift/linux/libswiftCore.so(function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> ()+0x14b) [0x7ffff7ab024b]
/data/swift/tori/.build/debug/tori() [0x424154]
/data/swift/tori/.build/debug/tori() [0x416536]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0) [0x7ffff52b4a40]
/data/swift/tori/.build/debug/tori() [0x415ef9]
Process 33 stopped
* thread #1: tid = 33, 0x00007ffff7ab024b libswiftCore.so`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> () + 331, name = 'tori', stop reason = signal SIGILL: illegal instruction operand
    frame #0: 0x00007ffff7ab024b libswiftCore.so`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> () + 331
libswiftCore.so`function signature specialization <preserving fragile attribute, Arg[2] = Dead, Arg[3] = Dead> of Swift._fatalErrorMessage (Swift.StaticString, Swift.StaticString, Swift.StaticString, Swift.UInt, flags : Swift.UInt32) -> ():
->  0x7ffff7ab024b <+331>: ud2    
    0x7ffff7ab024d <+333>: ud2    
    0x7ffff7ab024f <+335>: cmpl   $0x110000, %r13d          ; imm = 0x110000 
    0x7ffff7ab0256 <+342>: jae    0x7ffff7ab027f            ; <+383>

it seems to raise as soon as the db is trying to connect, line 43

Cannot use MongoKitten with Vapor HTTP

I'm new to Swift and I'm probably missing something. I can't compile after importing MK and Vapor HTTP as there is a clash with Server:

main.swift:5:13: reference to generic type 'Server' requires arguments in <...>

let server: Server!
            ^


** BUILD FAILED **

Is there a way of importing MK into a namespace?

clang symbols not found

Hi,
I have all the toolchains setup correctly. When I build from the command line I get a successful build. However when I try to build from Xcode the linker cannot link to the MongoKitten.swiftmodule.

Do I have to use a different version of clang?

Undefined symbols for architecture x86_64:
"MongoKitten.Server.__allocating_init (at : Swift.String, port : Swift.Int, using : (username : Swift.String, password : Swift.String)?, automatically : Swift.Bool) throws -> MongoKitten.Server", referenced from:
test.AppDelegate.applicationDidFinishLaunching (__ObjC.NSNotification) -> () in AppDelegate.o

ld: symbol(s) not found for architecture x86_64

Any idea?

Thanks,

Eddy

Cursor timeouts

I get hit with this
fatal error: Error fetching extra data from the server in MongoKitten.Cursor<heroku_6pxt0cxh.browseitems> with error: timeout: file /tmp/build_0e4a544672ea566050f30beb848fe070/Packages/MongoKitten-1.7.0/Sources/MongoKitten/Cursor.swift, line 79

Doesn't matter, happens on both read and writes.

I suspect it's related to https://jira.mongodb.org/browse/SERVER-8188

Any takes?

Connect works without a running MongoDB server

I'm more or less using the code from the tutorial:

let server: MongoKitten.Server!

do {
  server = try MongoKitten.Server(hostname: "localhost", port: 27017, automatically: true)
} catch {
  print("eep!")
  fatalError("Can't connect to MongoDB")
}

As a test I stopped the MondoDB server:

$ telnet localhost 27017
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

The app runs fine and just hangs when trying to insert a document into a collection. I looked at the source of Server.swift (bearing in mind that I only started using Swift yesterday) and the connect() method looks weird so I can't debug it.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.