Code Monkey home page Code Monkey logo

Comments (14)

robert-zaremba avatar robert-zaremba commented on June 8, 2024

πŸ‘ The functions would be much cleaner with special type for structure options.

from rethinkdb-go.

dancannon avatar dancannon commented on June 8, 2024

This is something that that I talked over with @crosbymichael and something I am still not sure about. Each method has a number of advantages and disadvantages.

Maps: There is not too much difference between this method and the current method however I agree it is more readable.
Structs: I agree this is by far the most readable and has the added benefit of having the required type checked at compile time (For example Durability must be a string in your example but with maps any value could be passed and the data must be validated for every function call). One issue I think might come up is that if structs are used then the driver will have to use the reflect package to convert the struct to a map to be sent to the database which is quite a bit of overhead.

I would be interested in getting a much feedback as possible regarding this issue before making a decision.

from rethinkdb-go.

robert-zaremba avatar robert-zaremba commented on June 8, 2024

I don't think this makes any overhead here we could measure ;)
As a simple solution (to avoid reflection) each structure can implement ToMap method, which can be used as an interface internally.

from rethinkdb-go.

jfbus avatar jfbus commented on June 8, 2024

πŸ‘ for toMap (non exported)

from rethinkdb-go.

dancannon avatar dancannon commented on June 8, 2024

One advantage that the use of a list of argName, argValue has is that if you are not passing any extra parameters if needed. For example:

With pairs

t.Insert(doc)

With maps

t.Insert(doc, r.OptArgs{})

from rethinkdb-go.

robert-zaremba avatar robert-zaremba commented on June 8, 2024
func (t RqlTerm) Insert(arg interface{}, optArgs ...r.OptArg) RqlTerm {
    var optArg r.OptArg
    if len(optArgs) == 0 {
        optArg = r.OptArg{}
    } else {
        optArg = optArgs[0]
    }
    ...
}

t.Insert(doc)

Although I prefer implicit version.

from rethinkdb-go.

ekanna avatar ekanna commented on June 8, 2024

Usage of optArgs, as currently implemented, is not easy to understand. Why not use a map or a struct ?
+1

from rethinkdb-go.

dancannon avatar dancannon commented on June 8, 2024

I am leaning towards using Maps and this is something I will work on soon.

from rethinkdb-go.

robert-zaremba avatar robert-zaremba commented on June 8, 2024

Structures might resolve this more clearly.

from rethinkdb-go.

jfbus avatar jfbus commented on June 8, 2024

Structures are definitively a good solution from a documentation point of view...

from rethinkdb-go.

dancannon avatar dancannon commented on June 8, 2024

Sorry I meant to say structures :D However I will look at both.

from rethinkdb-go.

dancannon avatar dancannon commented on June 8, 2024

I have added a new branch named dev which I will use to work on changes that make any API changes. Currently I have worked on updating the driver to use structs instead of the key/value string pairs.

If any of you could have a look at the changes that would be great.

from rethinkdb-go.

jfbus avatar jfbus commented on June 8, 2024

I'll look at it. If you want me to work on something, just tell me.

2013/11/16 Daniel Cannon [email protected]

I have added a new branch named dev which I will use to work on changes
that make any API changes. Currently I have worked on updating the driver
to use structs instead of the key/value string pairs.

If any of you could have a look at the changes that would be great.

β€”
Reply to this email directly or view it on GitHubhttps://github.com//issues/24#issuecomment-28628007
.

Jean-François Bustarret
http://jf.bustarret.com
http://www.sangetsueur.net - Jeu de simulation

from rethinkdb-go.

dancannon avatar dancannon commented on June 8, 2024

Thanks I will do.

from rethinkdb-go.

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.