Giter VIP home page Giter VIP logo

mongo.jl's Introduction

Mongo.jl

Build Status 0.6 Status Coverage Status

MongoDB bindings for The Julia Language

License

This software is licensed under the simplified BSD license; see the file LICENSE for details.

Installing

Building this package should build and/or install the MongoDB C driver for you.

Setup

You must have a MongoDB server running somewhere. You can specify the host and port in the MongoClient constructor, otherwise it uses the Mongo default locahost:27017.

using Mongo, LibBSON

# Create a client connection
client = MongoClient() # default locahost:27017

# Get a handle to collection named "cats" in database "db".
# Client object, database name, and collection name are stored as variables.
cats = MongoCollection(client, "db", "cats")

# Insert a document
# Mokie is a pretty old cat
m_oid = insert(cats, Dict("name" => "Mokie", "age" => 17))

Dictionary Syntax

With MongoDB, documents and queries are represented as BSONObject structures. In Julia, we can create these from Associative data structures like Dict. However, most functions in this package also accept a Union{Pair,Tuple} in lieu of that, allowing us to omit the Dict constructor:

# Pebbles is an even older cat
p_oid = insert(cats, ("name" => "Pebbles", "age" => 19))

# Ensure they were inserted by counting
println(count(cats, ("name" => "Mokie"))) # 1
println(count(cats)) # 2

Query Syntax

MongoDB queries are also BSON documents, and can include certain modifiers and operators which allow for the construction of complex queries. This package includes shortcut functions for many of them so, for instance instead of typing:

Dict("\$query" => Dict("age" => Dict("\$lt" => 19)))

We can do the following:

# Print all cats under age 19
for doc in find(cats, query("age" => lt(19)))
    println("$(doc["name"]) is younger than 19")
end

Operators and modifiers can be combined by encasing them in parenthesis.

# It's Mokie's birthday!
# We can use the shortcut for the "$inc" operator to increase Mokie's age by 1
update(cats, ("_id" => m_oid), inc("age" => 1))

for doc in find(cats, (query(), orderby("age" => 1)))
    println("$(doc["name"]) is $(doc["age"]) years old.")
end

# Delete the document and ensure it is no more by counting
delete(cats, ("_id" => m_oid))
println(count(cats, ("name" => "Mokie")))

Command Syntax

The command_simple function allows broad access to MongoDB actions. For example, creating an index:

command_simple(client,
               "db",
               Dict(
                  "createIndexes" => "cats",
                  "indexes" => [
                      Dict(
                          "key" => Dict("name" => 1),
                          "name" => "cats_name",
                          "unique" => 1)
                      ]
                  ))

command_simple returns a BSONObject reply, so you can also perform aggregations:

command_simple(client,
               "db",
               OrderedDict(
                  "aggregate" => "cats",
                  "pipeline" => [
                      Dict("\$match" => Dict("age" => 19)),
                      Dict("\$group" => Dict("_id" => "\$name", "count" => Dict("\$sum" => 1)))
                  ]
                )
              )

Refer to the MongoDB database commands docs for further commands.

Contributing

Contributions are welcome! Please fork on github.com and submit a pull request if you have a contribution you think is worthwhile!

mongo.jl's People

Contributors

felipenoris avatar innerlee avatar ivirshup avatar jeffbezanson avatar lytol avatar nnicandro avatar scottpjones avatar tkelman avatar turtleslow avatar zachallaun 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongo.jl's Issues

Insert fails in Julia v0.4

I am doing the following in Julia v0.4:

Pkg.add("Mongo")
using Mongo, LibBSON
client = MongoClient("mongodb://192.168.99.100:27017/")
collection = MongoCollection(client, "meteor", "widgets")
oid = insert(collection, {"name"=>"time series"})

where the last line, the insert method, gives a LoadError:

WARNING: deprecated syntax "{a=>b, ...}" at In[36]:1.
Use "Dict{Any,Any}(a=>b, ...)" instead.
LoadError: MethodError: convert has no method matching convert(::Type{Ptr{Void}}, ::Array{UInt8,1})
This may have arisen from a call to the constructor Ptr{Void}(...),
since type constructors fall back to convert methods.
Closest candidates are:
call{T}(::Type{T}, ::Any)
convert{T}(::Type{Ptr{T}}, !Matched::UInt64)
convert{T}(::Type{Ptr{T}}, !Matched::Int64)
...
while loading In[36], in expression starting on line 1

in insert at /Users/szalmaf/.julia/v0.4/Mongo/src/MongoCollection.jl:42

Do you have any suggestion as to how to resolve this error. It seems like the Mongo package was updated so that it can handle Julia v0.4, I am not sure why I am getting this error message.

Check if connection is successful

Aparently, the only way to check if a connection was successful is to try insert something in the database:

@testset "Mongo: bad host/port" begin
    client = MongoClient("bad-host-name", 9999)
    collection = MongoCollection(client, "foo", "bar")
    @test_throws ErrorException insert(collection, ("foo" => "bar"))
end

Even a query will return a iterator without errors, but with no data.

There should be a way to check if the connection to the host was successful.

ERROR: ArgumentError: cannot convert NULL to string

julia> docs = [doc for doc in find(foo, query("x"=>3))]
1-element Array{LibBSON.BSONObject,1}:
Error showing value of type Array{LibBSON.BSONObject,1}:
ERROR: ArgumentError: cannot convert NULL to string
in unsafe_string at ./strings/basic.jl:56 [inlined]
in convert(::Type{AbstractString}, ::LibBSON.BSONObject) at /Users/cacilhas/.julia/v0.5/LibBSON/src/BSONObject.jl:74
in show(::IOContext{Base.AbstractIOBuffer{Array{UInt8,1}}}, ::LibBSON.BSONObject) at /Users/cacilhas/.julia/v0.5/LibBSON/src/BSONObject.jl:86
in #sprint#316(::IOContext{Base.Terminals.TTYTerminal}, ::Function, ::Int64, ::Function, ::LibBSON.BSONObject, ::Vararg{LibBSON.BSONObject,N}) at ./strings/io.jl:35
in (::Base.#kw##sprint)(::Array{Any,1}, ::Base.#sprint, ::Int64, ::Function, ::LibBSON.BSONObject, ::Vararg{LibBSON.BSONObject,N}) at ./:0
in alignment(::IOContext{Base.Terminals.TTYTerminal}, ::Array{LibBSON.BSONObject,1}, ::Array{Int64,1}, ::Array{Int64,1}, ::Int64, ::Int64, ::Int64) at ./show.jl:1278
in print_matrix(::IOContext{Base.Terminals.TTYTerminal}, ::Array{LibBSON.BSONObject,1}, ::String, ::String, ::String, ::String, ::String, ::String, ::Int64, ::Int64) at ./show.jl:1407
in print_matrix(::IOContext{Base.Terminals.TTYTerminal}, ::Array{LibBSON.BSONObject,1}, ::String, ::String, ::String) at ./show.jl:1379
in #showarray#342(::Bool, ::Function, ::IOContext{Base.Terminals.TTYTerminal}, ::Array{LibBSON.BSONObject,1}, ::Bool) at ./show.jl:1618
in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::Array{LibBSON.BSONObject,1}) at ./REPL.jl:132
in display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Array{LibBSON.BSONObject,1}) at ./REPL.jl:135
in display(::Array{LibBSON.BSONObject,1}) at ./multimedia.jl:143
in print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:154
in print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:139
in (::Base.REPL.##22#23{Bool,Base.REPL.##33#42{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:652
in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at ./LineEdit.jl:1579
in run_interface(::Base.Terminals.TTYTerminal, ::Base.LineEdit.ModalInterface) at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?
in run_frontend(::Base.REPL.LineEditREPL, ::Base.REPL.REPLBackendRef) at ./REPL.jl:903
in run_repl(::Base.REPL.LineEditREPL, ::Base.##950#951) at ./REPL.jl:188
in _start() at ./client.jl:363
in _start() at /Applications/Julia-0.5.app/Contents/Resources/julia/lib/julia/sys.dylib:?

Authentication support

Is Mongodb authentication supported? or likely to be added?

I have a mongodb that must be authenticated, but this appears to be the best Julia package I can find to interact with it.

Problem installing mongo.jl on Mac OS

I am new to Julia and am trying to use the Mongo package. I am using Julia 0.4.6 on Mac OS 10.11.6. When I try to add (or build) the package using Pkg.add("Mongo") or Pkg.build("Mongo")I get the error:

"Error: Cannot install mongo-c because conflicting formulae are installed.
libbson: because mongo-c installs the libbson headers
Please brew unlink libbson before continuing.

Unlinking removes a formula's symlinks from /Users/whitney/.julia/v0.4/Homebrew/deps/usr. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side-effects in the
resulting software."

I then tried to unlink libbson using: Homebrew.brew(unlink libbson) and then tried building Mongo again, but had the same error.

mongoc_bulk_operation_execute

Has anyone created a binding for Bulk insert. We are so surprise at how slow insert is. Attempting to create a bulk insert function.

Support for 1.0

What is the status for 1.0, please?
I see some commits that address this issue, but it fails for me (macOS):

(v1.0) pkg> add Mongo
 Resolving package versions...
 Installed Mongo ─── v0.3.0
 Installed LibBSON ─ v0.3.0
  Updating `~/.julia/environments/v1.0/Project.toml`
  [f08002d9] + Mongo v0.3.0
  Updating `~/.julia/environments/v1.0/Manifest.toml`
  [d9be37ee] + Homebrew v0.7.0
  [b5cb2838] + LibBSON v0.3.0
  [f08002d9] + Mongo v0.3.0
  Building LibBSON  `~/.julia/packages/LibBSON/2p4EI/deps/build.log`
┌ Error: Error building `LibBSON`:
│ ERROR: LoadError: LoadError: UndefVarError: is_apple not defined
│ Stacktrace:
│  [1] top-level scope at none:0
│  [2] eval at ./boot.jl:319 [inlined]
│  [3] @static(::LineNumberNode, ::Module, ::Any) at ./osutils.jl:19
│  [4] include at ./boot.jl:317 [inlined]
│  [5] include_relative(::Module, ::String) at ./loading.jl:1038
│  [6] include(::Module, ::String) at ./sysimg.jl:29
│  [7] include(::String) at ./client.jl:388
│  [8] top-level scope at none:0in expression starting at /Users/adrian/.julia/packages/LibBSON/2p4EI/deps/build.jl:21in expression starting at /Users/adrian/.julia/packages/LibBSON/2p4EI/deps/build.jl:21
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1068
  Building Mongo ── `~/.julia/packages/Mongo/w1nap/deps/build.log`
┌ Error: Error building `Mongo`:
│ ERROR: LoadError: LoadError: UndefVarError: is_apple not defined
│ Stacktrace:
│  [1] top-level scope at none:0
│  [2] eval at ./boot.jl:319 [inlined]
│  [3] @static(::LineNumberNode, ::Module, ::Any) at ./osutils.jl:19
│  [4] include at ./boot.jl:317 [inlined]
│  [5] include_relative(::Module, ::String) at ./loading.jl:1038
│  [6] include(::Module, ::String) at ./sysimg.jl:29
│  [7] include(::String) at ./client.jl:388
│  [8] top-level scope at none:0in expression starting at /Users/adrian/.julia/packages/Mongo/w1nap/deps/build.jl:21in expression starting at /Users/adrian/.julia/packages/Mongo/w1nap/deps/build.jl:21
└ @ Pkg.Operations /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.0/Pkg/src/Operations.jl:1068

(v1.0) pkg> add Mongo#master
   Cloning git-repo `https://github.com/ScottPJones/Mongo.jl.git`
  Updating git-repo `https://github.com/ScottPJones/Mongo.jl.git`
 Resolving package versions...
  Updating `~/.julia/environments/v1.0/Project.toml`
  [f08002d9]  Mongo v0.3.0  v0.3.0+ #master (https://github.com/ScottPJones/Mongo.jl.git)
  Updating `~/.julia/environments/v1.0/Manifest.toml`
  [f08002d9]  Mongo v0.3.0  v0.3.0+ #master (https://github.com/ScottPJones/Mongo.jl.git)
  Building Mongo  `~/.julia/packages/Mongo/XbZhn/deps/build.log`

julia> using Mongo
[ Info: Precompiling Mongo [f08002d9-bb2c-5ca6-9977-d4081ea2ff9e]
┌ Warning: Package Mongo does not have Libdl in its dependencies:- If you have Mongo checked out for development and have
│   added Libdl as a dependency but haven't updated your primary
│   environment's manifest file, try `Pkg.resolve()`.
│ - Otherwise you may need to report an issue with Mongo
└ Loading Libdl into Mongo from project dependency, future warnings for Mongo are suppressed.
ERROR: LoadError: could not open file /Users/adrian/.julia/packages/LibBSON/2p4EI/deps/deps.jl
Stacktrace:
 [1] include at ./boot.jl:317 [inlined]
 [2] include_relative(::Module, ::String) at ./loading.jl:1038
 [3] include at ./sysimg.jl:29 [inlined]
 [4] include(::String) at /Users/adrian/.julia/packages/LibBSON/2p4EI/src/LibBSON.jl:1
 [5] top-level scope at none:0
 [6] include at ./boot.jl:317 [inlined]
 [7] include_relative(::Module, ::String) at ./loading.jl:1038
 [8] include(::Module, ::String) at ./sysimg.jl:29
 [9] top-level scope at none:2
 [10] eval at ./boot.jl:319 [inlined]
 [11] eval(::Expr) at ./client.jl:389
 [12] top-level scope at ./none:3
in expression starting at /Users/adrian/.julia/packages/LibBSON/2p4EI/src/LibBSON.jl:5
ERROR: LoadError: Failed to precompile LibBSON [b5cb2838-5506-56c8-b038-21e3582abe5d] to /Users/adrian/.julia/compiled/v1.0/LibBSON/yHlPa.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1184
 [4] _require(::Base.PkgId) at ./logging.jl:311
 [5] require(::Base.PkgId) at ./loading.jl:852
 [6] macro expansion at ./logging.jl:311 [inlined]
 [7] require(::Module, ::Symbol) at ./loading.jl:834
 [8] include at ./boot.jl:317 [inlined]
 [9] include_relative(::Module, ::String) at ./loading.jl:1038
 [10] include(::Module, ::String) at ./sysimg.jl:29
 [11] top-level scope at none:2
 [12] eval at ./boot.jl:319 [inlined]
 [13] eval(::Expr) at ./client.jl:389
 [14] top-level scope at ./none:3
in expression starting at /Users/adrian/.julia/packages/Mongo/XbZhn/src/Mongo.jl:17
ERROR: Failed to precompile Mongo [f08002d9-bb2c-5ca6-9977-d4081ea2ff9e] to /Users/adrian/.julia/compiled/v1.0/Mongo/NbAnB.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1184
 [4] macro expansion at ./logging.jl:311 [inlined]
 [5] _require(::Base.PkgId) at ./loading.jl:941
 [6] require(::Base.PkgId) at ./loading.jl:852
 [7] macro expansion at ./logging.jl:311 [inlined]
 [8] require(::Module, ::Symbol) at ./loading.jl:834

julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin14.5.0)
  CPU: Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, skylake)

julia>

Creating index(es) using Mongo.jl

Is there a way to create indexes on a particular column using Mongo.jl?

I was looking for an API that replicates this function db.collection.createIndex()

Cannot import Mongo while on Mac

Hi, I am trying to use the package on Julia 0.6.1, and have troubles using the package. Here is the error I get,

julia> using Mongo, LibBSON
ERROR: LoadError: could not open file /Users/rahullakhanpal/.julia/v0.6/Mongo/src/../deps/deps.jl
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:576
 [2] include(::String) at ./sysimg.jl:14
 [3] include_from_node1(::String) at ./loading.jl:576
 [4] eval(::Module, ::Any) at ./boot.jl:235
 [5] _require(::Symbol) at ./loading.jl:490
 [6] require(::Symbol) at ./loading.jl:405
while loading /Users/rahullakhanpal/.julia/v0.6/Mongo/src/Mongo.jl, in expression starting on line 3

Can't open file Mongo.jl, deps.jl, libBSON, etc.

Hi,

I have Julia 0.3, Mongodb-osx-x86_64-3.0.4, and Mongo-c-driver-1.1.9 installed, but can't get Julia to access the Mongo Client through this 'untestable' package https://github.com/pzion/Mongo.jl, according to http://pkg.julialang.org/.

I have tried Lytol/Mongo.jl and the command require("Mongo.jl") can't open file Mongo.jl, or the auto-generated deps.jl.

I will attempt to debug it and publish my findings on Github.

Connection to Julia users on Google Groups https://groups.google.com/d/msg/julia-users/h4NxY6vLdnM/YT7B_UOWZZsJ

Accessing invalid BSON field yields inconsistent state

In the example below, result is a valid BSONObject instance that doesn't have hey as a key.

Sometimes I also get segfaults.

julia> result["hey"]
ERROR: key not found: "hey"
Stacktrace:
 [1] getindex(::LibBSON.BSONObject, ::String) at /Users/felipenoris/.julia/v0.6/LibBSON/src/BSONIter.jl:80

julia> result
Error showing value of type LibBSON.BSONObject:
ERROR: ArgumentError: cannot convert NULL to string
Stacktrace:
 [1] unsafe_string at ./strings/string.jl:39 [inlined]
 [2] convert(::Type{AbstractString}, ::LibBSON.BSONObject) at /Users/felipenoris/.julia/v0.6/LibBSON/src/BSONObject.jl:75
 [3] show(::IOContext{Base.Terminals.TTYTerminal}, ::LibBSON.BSONObject) at /Users/felipenoris/.julia/v0.6/LibBSON/src/BSONObject.jl:86
 [4] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/plain")}, ::LibBSON.BSONObject) at ./REPL.jl:122
 [5] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::LibBSON.BSONObject) at ./REPL.jl:125
 [6] display(::LibBSON.BSONObject) at ./multimedia.jl:218
 [7] eval(::Module, ::Any) at ./boot.jl:235
 [8] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [9] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [10] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646

Refactor mongo operators

The current design, Mongo.jl overloads some Base functions in order to implement mongo operators.

In my opinion, this is a bad idea. For instance, the definition of in clashes with the definition in Compat, since it is defined for in(::Any).

I would like to propose to use a different namespace for Mongo operators, instead of overloading functions from Base.

Another possibility, preferable in my opinion, is to refactor these definitions to multiple-dispatch to a data-structure that is defined in this package. This way Base functions may be overloaded safely.

WARNING: Method definition in(Any) in module Compat at /Users/felipenoris/.julia/v0.6/Compat/src/Compat.jl:912 overwritten in module Mongo at /Users/felipenoris/.julia/v0.6/Mongo/src/query.jl:21.

Info about upcoming removal of packages in the General registry

As described in https://discourse.julialang.org/t/ann-plans-for-removing-packages-that-do-not-yet-support-1-0-from-the-general-registry/ we are planning on removing packages that do not support 1.0 from the General registry. This package has been detected to not support 1.0 and is thus slated to be removed. The removal of packages from the registry will happen approximately a month after this issue is open.

To transition to the new Pkg system using Project.toml, see https://github.com/JuliaRegistries/Registrator.jl#transitioning-from-require-to-projecttoml.
To then tag a new version of the package, see https://github.com/JuliaRegistries/Registrator.jl#via-the-github-app.

If you believe this package has erroneously been detected as not supporting 1.0 or have any other questions, don't hesitate to discuss it here or in the thread linked at the top of this post.

'count' doesn't work with 'query' shortcut i.e. to do gt, lt, ne, eq queries

It would be helpful if the query shortcut worked for count as it does for find find

For instance, to find records that are not equal to a value:

for doc in find(collection, query("state" => ne("ma")))
...
end

The above works, but the following doesn't

numdocs = count(collection, query("state" => ne("ma")))

ReplicaSet, Insert

I try to make an insert with Mongo.jl and following uri.
With simple uri (someurl:27015) there is no issue. If the uri includes ReplicaSet it stuck.

mongodb://<user>:<password>@c47.cockney.0.mongolayer.com:10047,c47.cockney.1.mongolayer.com:10047/shopco_ml?replicaSet=set-542aa5fee8270e9654005f6a

I use this code:

mongoUser = ... # user 
mongoPass= ... # password
serverUrlBest = "mongodb://$(mongoUser):$(mongoPass)@c47.cockney.0.mongolayer.com:10047,c47.cockney.1.mongolayer.com:10047/shopco_ml?replicaSet=set-542aa5fee8270e9654005f6a"

client = MongoClient(serverUrlBest)

# Get a handle to collection named "try_coll" in database "try_db"
collection = MongoCollection(client, "try_db", "try_coll")
2015/02/20 14:59:32.0173: [36443]:    DEBUG:      cluster: Client initialized in replica set mode.
bsonObject = BSONObject({"ping" => "pong"})
# Insert a document
insert(collection, bsonObject)
2015/02/20 14:59:32.0739: [36443]:    DEBUG:      cluster: Reconnecting to replica set.
2015/02/20 14:59:32.0861: [36443]:    DEBUG:      cluster: Registering potential peer: c47.cockney.0.mongolayer.com:10047
2015/02/20 14:59:32.0861: [36443]:    DEBUG:      cluster: Registering potential peer: c47.cockney.1.mongolayer.com:10047
2015/02/20 14:59:32.0861: [36443]:     INFO:      cluster: c47.cockney.0.mongolayer.com:10047: Got replicaSet "set-542aa5fee8270e4354005f6a" expected "set-542aa5fee8270e4354005f6a:27017/".
2015/02/20 14:59:32.0976: [36443]:    DEBUG:      cluster: Registering potential peer: c47.cockney.1.mongolayer.com:10047
2015/02/20 14:59:32.0976: [36443]:    DEBUG:      cluster: Registering potential peer: c47.cockney.0.mongolayer.com:10047
2015/02/20 14:59:32.0976: [36443]:     INFO:      cluster: c47.cockney.1.mongolayer.com:10047: Got replicaSet "set-542aa5fee8270e4354005f6a" expected "set-542aa5fee8270e4354005f6a:27017/".
2015/02/20 14:59:33.0061: [36443]:    DEBUG:      cluster: Registering potential peer: c47.cockney.0.mongolayer.com:10047
2015/02/20 14:59:33.0061: [36443]:    DEBUG:      cluster: Registering potential peer: c47.cockney.1.mongolayer.com:10047
2015/02/20 14:59:33.0061: [36443]:     INFO:      cluster: c47.cockney.0.mongolayer.com:10047: Got replicaSet "set-542aa5fee8270e4354005f6a" expected "set-542aa5fee8270e4354005f6a:27017/".
insert: No acceptable peer could be found.
while loading In[4], in expression starting on line 3

 in error at error.jl:21
 in insert at /Users/amr5hgku30unjdfk44e3/.julia/v0.3/Mongo/src/MongoCollection.jl:45

Building error with Julia 0.4.5 on Mac

I install Julia 0.4.5 on OSX 10.11.4 by Homebrew.
when I use Pkg.update() and then Pkg.add("Mongo"), the install informations were as follows:

INFO: Installing BinDeps v0.3.21
INFO: Installing Compat v0.7.14
INFO: Installing Homebrew v0.2.0
INFO: Installing JSON v0.5.0
INFO: Installing LibBSON v0.2.1
INFO: Installing Mongo v0.2.0
INFO: Installing SHA v0.1.2
INFO: Installing URIParser v0.1.3
INFO: Building Homebrew
INFO: Recompiling stale cache file /Users/Home/.julia/lib/v0.4/Compat.ji for module Compat.
INFO: Recompiling stale cache file /Users/Home/.julia/lib/v0.4/JSON.ji for module JSON.
INFO: Recompiling stale cache file /Users/Home/.julia/lib/v0.4/SHA.ji for module SHA.
INFO: Recompiling stale cache file /Users/Home/.julia/lib/v0.4/BinDeps.ji for module BinDeps.
HEAD is now at 53c5089 CoreTap#install: fix clone target setting
HEAD is now at d45fe22 Merge pull request #91 from staticfloat/staging
INFO: Building LibBSON

WARNING: deprecated syntax "{a=>b, ...}" at /Users/Home/.julia/v0.4/LibBSON/deps/build.jl:12.
Use "Dict{Any,Any}(a=>b, ...)" instead.

WARNING: deprecated syntax "{a=>b, ...}" at /Users/Home/.julia/v0.4/LibBSON/deps/build.jl:23.
Use "Dict{Any,Any}(a=>b, ...)" instead.

WARNING: deprecated syntax "[a=>b, ...]" at /Users/Home/.julia/v0.4/LibBSON/deps/build.jl:26.
Use "Dict(a=>b, ...)" instead.
INFO: Building Mongo

WARNING: deprecated syntax "{a=>b, ...}" at /Users/Home/.julia/v0.4/Mongo/deps/build.jl:12.
Use "Dict{Any,Any}(a=>b, ...)" instead.

WARNING: deprecated syntax "{a=>b, ...}" at /Users/Home/.julia/v0.4/Mongo/deps/build.jl:23.
Use "Dict{Any,Any}(a=>b, ...)" instead.

WARNING: deprecated syntax "[a=>b, ...]" at /Users/Home/.julia/v0.4/Mongo/deps/build.jl:26.
Use "Dict(a=>b, ...)" instead.
Error: Cannot install mongo-c because conflicting formulae are installed.

  libbson: because mongo-c installs the libbson headers

Please `brew unlink libbson` before continuing.

Unlinking removes a formula's symlinks from /Users/Home/.julia/v0.4/Homebrew/deps/usr. You can
link the formula again after the install finishes. You can --force this
install, but the build may fail or cause obscure side-effects in the
resulting software.
================================[ ERROR: Mongo ]================================

LoadError: failed process: Process(`/Users/Home/.julia/v0.4/Homebrew/deps/usr/bin/brew install --force-bottle mongo-c`, ProcessExited(1)) [1]
while loading /Users/Home/.julia/v0.4/Mongo/deps/build.jl, in expression starting on line 26

================================================================================


================================[ BUILD ERRORS ]================================

WARNING: Mongo had build errors.

 - packages with build errors remain installed in /Users/Home/.julia/v0.4
 - build the package(s) and all dependencies with `Pkg.build("Mongo")`
 - build a single package by running its `deps/build.jl` script

================================================================================
INFO: Package database updated

command_simple not working

The command_simple() function doesn't seem to be working.

In fact, I'm trying to duplicate the examples provided in the README.md, and the command_simple() function doesn't even seem to be available. I'm getting an error that suggests it is not defined. Am I missing something?

I'm using Julia 0.4.5, and I just ran Pkg.checkout("Mongo") and Pkg.build("Mongo").

Implement findfirst

Currently this is the only way to get the first element of the collection:

first(find( ... ))

Also, there's no way to check wether find returned an empty iterator.

Limit Results

How do you limit results in a query?

I've tired the following, to limit to 10 docs:

for doc in find(collection, query, 0, 10)
println(doc)
end

But I get this error:
'find' has no method matching find(::MongoCollection, ::Dict{Any, Any}, ::Int64, ::Int64)

Thank you for your help!

update() deletes other fields not explicitly stated in update query

My understanding is that the update function should just affect the fields stated in the update query, but it seems to delete every other field in the record, leaving just the updated field.

oid = insert(collection,("a" => 1,"b"=>2,"c"=>3)
update(collection, ("_id" => did), ("a" => 323))

Result:
("a" => 323)

not
("a" => 323,"b"=>2,"c"=>3)

Cannot build Mongo after upgrading to Julia-0.6

When trying to build Mongo.jl after I upgraded from Julia0.5 to Julia0.6 I get the error message:

=====================================================================================================================================================================
INFO: Building Mongo
==========================================================================[ ERROR: Mongo ]===========================================================================

LoadError: UndefVarError: @osx_only not defined
while loading /Users/xxx/.julia/v0.6/Mongo/deps/build.jl, in expression starting on line 21

Is this an issue with Mongo.jl?

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.