Coder Social home page Coder Social logo

Comments (7)

JamesCropcho avatar JamesCropcho commented on June 11, 2024

Thanks for writing, Mariuis ( @mariusbancos ). I hope Variety is working well for you, overall.

Let's look at the example in the linked documentation section:

$ mongo test --eval "var collection = 'users', query = {'caredAbout':true}" variety.js

So, anybody correct me if I'm wrong, but query "takes a standard Mongo[DB] query object," meaning that we more or less pass this value through to MongoDB. To that end, I suspect that referencing the relevant MongoDB documentation for whichever version you're using, would be the correct path to take.

Does that help?

from variety.

mariusbancos avatar mariusbancos commented on June 11, 2024

So, @JamesCropcho, in fact I'm using variety-cli (but I guess it's the same problem with variety) the problem is that if I write the following command

variety-cli {MONGODB_CONNECTION_PARAMS} --quiet --query='{"company": ObjectId("5a6b446d46246c5b6eaaa4a4")}' --outputFormat='json'

I get the following error

(node:4328) UnhandledPromiseRejectionWarning: Error: Failed to parse option 'query': End of input while parsing an object (missing '}') at line 1,49 >>>"company": ObjectId( ...
    at Object.parseHson [as parser]

Maybe it's a better example this.
Let me know how to solve it.
Regards.

from variety.

JamesCropcho avatar JamesCropcho commented on June 11, 2024

Thanks for getting back to us, @mariusbancos.

Huh, this one is a bit of a stumper (not to mention that I personally don't have much Variety-CLI experience).

@todvora, do you happen to see anything funny there?

―James

from variety.

JamesCropcho avatar JamesCropcho commented on June 11, 2024

Sorry we cannot be of assistance to you, @mariusbancos. It sounds like nobody has any idea. I'm going to leave this issue open, however, in the hopes that someday an individual sees this thread, who is able to address it.

from variety.

todvora avatar todvora commented on June 11, 2024

Hi,
Sorry for my (very delayed) response! I somehow missed that there is this issue.

I confirm that there is a problem. If I call directly Variety without variety-cli, it works:

mongo myDb --eval "var collection = 'myCollection', query={'_id':ObjectId('599676b91ad81078a0d473c9')}" variety.js

But when I try to do the same via variety-cli, it fails as you describe. The first problem is that variety-cli parses the query expression and the ObjectId is a reference to an unknown type in variety-cli (it doesn't use mongo directly, only helps to prepare the CLI command).

I'll check the code and see if there is anything I can do to make it work. Meanwhile you can use directly the original Variety without the variety-cli wrapper, it should work for you.

Thanks,
Tomas

from variety.

mariusbancos avatar mariusbancos commented on June 11, 2024

Hello @todvora , indeed with variety-cli is working as expected. For the moment I'll use it like this. Maybe in the future you'll fix this in variety-cli also.
Thanks for your support,
Marius

from variety.

JamesCropcho avatar JamesCropcho commented on June 11, 2024

Truly happy that we can help, Marius ( @mariusbancos ).

Be in touch further if you need anything else.

―J

from variety.

Related Issues (20)

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.