Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

README instructions don't work #19

Closed
svanimpe opened this issue Mar 5, 2016 · 5 comments
Closed

README instructions don't work #19

svanimpe opened this issue Mar 5, 2016 · 5 comments

Comments

@svanimpe
Copy link

svanimpe commented Mar 5, 2016

The following code is not valid Swift and doesn't work:

let data = [
    "name": "Dan",
    "age": 15,
    "lovesProgramming" : true,
    "location": [
        "state": "California"
    ]
    "favoriteNumbers" : [1,2,3,4,5]
]

let subject = MongoDocument(data)
@Danappelxx
Copy link
Owner

Right, don't know how I missed that.

I'll fix it in a couple days when I have the time but until then I'm happy to take a pr 😃

@svanimpe
Copy link
Author

svanimpe commented Mar 5, 2016

I'm not sure I want to honestly 😉 I was trying out SwiftMongoDB, but find it really confusing. MongoDocument wraps DocumentData, which is a typealias for BSON.Document which is again a typealias for [String: BSON.Value] where BSON.Value is an enumerated type whose cases wrap the actual values you want to store... If you're developing on Linux, where you don't have autocompletion or 'Go to declaration', this is all really hard to use.

@Danappelxx
Copy link
Owner

I was about to start a major refactor where the MongoDocument type will disappear and will simply become BSON.Document. The reason that it's so messy right now is because previously DocumentData was [String:Any] but when I switched to the BSON enum I was trying to make the minimal amount of changes for it to work. Thanks for the interest, though! Stuff will be much better soon 😃.

@Danappelxx
Copy link
Owner

I just made most BSON.Value types conform to their respective -Convertible, so this is now possible, and it's actually even less code (this is on the refactor branch).

let dan: BSON.Document = [
    "name": "Dan",
    "age": 15,
    "lovesProgramming" : true,
    "location": [
        "state": "California"
    ]
    "favoriteNumbers" : [1,2,3,4,5]
]

For a more detailed example I suggest taking a look at the unit test here.

Readme will be updated with proper documentation soon...

@Danappelxx
Copy link
Owner

Fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants