Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dbInsertDocument not supporting array of document #22

Open
RockScience opened this issue Oct 28, 2013 · 4 comments
Open

dbInsertDocument not supporting array of document #22

RockScience opened this issue Oct 28, 2013 · 4 comments

Comments

@RockScience
Copy link

Is dbInsertDocument a simple wrapper of db.collection.insert() ?

According to http://docs.mongodb.org/manual/reference/method/db.collection.insert/#db.collection.insert it should support batch sending from an array of document:

[document1, document2, ..., documentN]

This is important because R is not a compiled language and doesn't deal well with loops. Hence not being able to send a batch of documents will create unnecessary delays.

See also StackOverflow question:
http://stackoverflow.com/questions/19564321/how-to-send-multiple-documents-using-rmongo

@RockScience
Copy link
Author

I suspect line 64 of RMongo / src / r-mongo-scala / src / main / scala / rmongo / RMongo.scala
is not parsing correctly arrays of documents:

64: JSON.parse(query).asInstanceOf[DBObject]

@tc
Copy link
Owner

tc commented Oct 28, 2013

To make this fix, i think you'll need to make another function named
dbInsertDocuments and typecast to a List[DBObject] instead of DBObject on
L64 as you mentioned.

Additionally, it helps to add a unit test to verify the fix. To compile and
run the tests, just run:

mvn compile and mvn test

You'll need Maven 3/Java 7+ installed.

On Mon, Oct 28, 2013 at 12:22 AM, RockScience [email protected]:

I suspect line 64 of RMongo / src / r-mongo-scala / src / main / scala /
rmongo / RMongo.scala
is not parsing correctly arrays of documents:

64: JSON.parse(query).asInstanceOf[DBObject]


Reply to this email directly or view it on GitHubhttps://github.com//issues/22#issuecomment-27193043
.

Tommy Chheng

@RockScience
Copy link
Author

Any progress on this? Being able to send arrays of documents without a loop is a native feature of mongodb API which is very important for a scripting language like R.

@tc
Copy link
Owner

tc commented Mar 11, 2015

Hi, if you submit a pull request with the suggested changes above, i'll be more than happy to review and merge.

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

No branches or pull requests

2 participants