Giter Club home page Giter Club logo

mgs's People

Contributors

ajclopez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

mgs's Issues

How to find by ObjectId?

I hope this message finds you well. I wanted to reach out to express my gratitude for the wonderful tool you've developed.

Question:
My entity in MongoDB:

{
  "_id": {
    "$oid": "666fde1af688038e64d6b58a"
  },
  "warehouseId": {
    "$oid": "666f3a3ecf615a0f4d455411"
  }
}

Code:

query:= "warehouseId=666f3a3ecf615a0f4d455411"
opts := mgs.FindOption()
result, mgsErr := mgs.MongoGoSearch(query, opts)
entity, err = collection.Find(context.TODO(), result.Filter, findOpts)

AR: entity is not found.

How can I find the entity by the query? I understand that it is not found because "warehouseId" is an ObjectId, not a string.

As a workaround, I can do this:

filter := result.Filter["$and"][0].(map[string]interface{})
filter ["warehouseId"]=primitive.ObjectIDFromHex(filter ["warehouseId"])
entity, err = collection.Find(context.TODO(), result.Filter, findOpts)

AR: entity is found.

I see that for this purpose Casters exist, but it doesn't have an OBJECT_ID caster.

Is there any other way to find the entity by the query?

If not, do you agree that this functionality is required? If you agree but don't have time to implement it, we can discuss the design here and I will prepare a PR. The easiest way would be to just add a new caster OBJECT_ID, but I think this is not the best solution because it will create a dependency on the MongoDB driver. I think an extension point can be created to avoid dependency on the driver.

Advanced searching using POST api

Hey @ajclopez
I was going through the library and it seems very useful. However, there was one thing that I wanted to discuss which is the length of the query param in case of advanced search. Suppose there is multiple level of nested query like (((A OR B) AND (C AND D)) OR E.... where A,B,C,D,E could be filed names or queries in themselves. Thus scalability could be an issue in case of big queries. Could this be done in a POST call where there is a JSON payload (dont know how it would look like) which gets converted to BSON at the server level?

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.