Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Sep 26 22:12
    CodyDWJones edited #499
  • Sep 26 22:12
    CodyDWJones opened #499
  • Sep 26 20:07
    CodyDWJones closed #498
  • Sep 24 17:24
    CodyDWJones commented #497
  • Sep 24 17:06
    CodyDWJones closed #497
  • Sep 23 21:42
    CodyDWJones commented #498
  • Sep 23 14:35
    CMogilko commented #498
  • Sep 23 13:49

    CMogilko on master

    Upgrade to Python 3.8 (#496) *… (compare)

  • Sep 23 13:49
    CMogilko closed #496
  • Sep 23 13:47

    CMogilko on master

    Make it easier for new contribu… (compare)

  • Sep 23 13:47
    CMogilko closed #495
  • Sep 23 13:45

    CMogilko on master

    Fix failing Travis CI jobs (#49… (compare)

  • Sep 23 13:45
    CMogilko closed #494
  • Sep 20 16:40
    CodyDWJones edited #498
  • Sep 16 16:47
    CodyDWJones synchronize #498
  • Sep 16 16:26
    CodyDWJones synchronize #498
  • Sep 16 05:23
    CodyDWJones synchronize #498
  • Sep 16 03:47
    CodyDWJones synchronize #498
  • Sep 15 23:55
    CodyDWJones synchronize #498
  • Sep 15 18:10
    CodyDWJones synchronize #498
Fredrik Forsmo
@frozzare
awesome!
José Coelho
@jacoelho

hello,

I'm trying to querying the following data:

{
"id":  "123456789" ,
"stuff": {
  "stuff_one":  "123456" ,
  "stuff_two": {
    "name":  "stuff" ,
    "description":  "something"
  }
}

Using data explorer: r.db('test').table('description').get('123456789').getField('stuff'):

{
  "stuff_one":  "123456" ,
  "stuff_two": {
    "name":  "stuff" ,
    "description":  "something"
  }

using gorethink: r.Table("description").Get('123456789').Field('stuff')

{%!V(string=123456) {%!V(string=) %!V(string=)}}

what am I missing here?
Suyash Katiyar
@skatiyar
import "fmt"
import r "github.com/dancannon/gorethink"

func main() {
    conn, connErr := r.Connect(r.ConnectOpts{Address: "localhost:21015"})
    if connErr != nil {
        fmt.Println(connErr)
        return
    }

    query, queryErr := r.Table("test").Get("123456789").Field("stuff").Run(conn)
    if queryErr != nil {
        fmt.Println(queryErr)
        return
    }

    var ole interface{}
    if scanErr := query.One(&ole); scanErr != nil {
        fmt.Println(scanErr)
        return
    }

    fmt.Println(ole)
}
Works fine for me, try checking for errors.
@jacoelho it prints map[stuff_one:123456 stuff_two:map[description:something name:stuff]]
José Coelho
@jacoelho
hmm, thank you! I will recheck it
Daniel Cannon
@dancannon
@jacoelho it looks like you were not actually calling Run(session), @SKatiyar answer should work but if you are still having issues could you please post the code you are trying to use.
José Coelho
@jacoelho
after some debug:
r.Table("description").EqJoin("id", r.Table("products"), r.EqJoinOpts{Index: "description_id"}).Zip().Filter(map[string]interface{}{"id": d.Id}).Field("settings").Run(session)

map[description_id:123456789 id:987654321 name:something stuff:map[stuff_one:123456 stuff_two:map[name: description:]]]
but this query:
r.Table("description").Get("123456789").Field("settings").Run(session)

map[stuff_one:123456 stuff_two:map[name:stuff description:something]
no clue :/
Suyash Katiyar
@skatiyar
@jacoelho can you give some sample dataset and exact problem you are facing??
Elie Zedeck RANDRIAMIANDRIRAY
@eliezedeck
@dancannon is there a way to know more about the generated Errors. For example, in case of table already existing, is there a kind of error code (instead of error string) to compare to rather than checking the error message if it contains the text "already exists" or not?
Daniel Cannon
@dancannon
@eliezedeck Unfortunately not, for example this is what the driver gets back from RethinkDB
{"t":18,"e":4100000,"r":["Table `examples.games` already exists."],"b":[],"p":[{"duration(ms)":0.343791}]}
Elie Zedeck RANDRIAMIANDRIRAY
@eliezedeck
isn't the "e" item here the error identifier? I mean, for instance, all table already existing error message would always return "e" = 4100000, right?
if that is the case, that might be something that could be exported all the way to the error itself... it's more comfortable to trust the value of the "e" rather that the message that has higher chance of being updated in the future
Daniel Cannon
@dancannon
@eliezedeck Apologies you are completely correct!
The driver spec is missing that field so I completely ignored it haha
If you could create an issue on Github I will make sure it gets added in the next version
Elie Zedeck RANDRIAMIANDRIRAY
@eliezedeck
Sure... :)
Elie Zedeck RANDRIAMIANDRIRAY
@eliezedeck
@dancannon it's done
Daniel Cannon
@dancannon
Great thanks! Not sure when the next release will be but hopefully not too long
Elie Zedeck RANDRIAMIANDRIRAY
@eliezedeck
Cool! Thank YOU!
Suyash Katiyar
@skatiyar
@dancannon trying to load http://apps.sfgov.org/datafiles/view.php?file=sfgis/citylots.zip data into rethinkdb using gorethink
package main

import "fmt"

import r "github.com/dancannon/gorethink"
import "encoding/json"
import "io/ioutil"
import "reflect"

func main() {
    conn, connErr := r.Connect(r.ConnectOpts{Address: "localhost:21015"})
    if connErr != nil {
        fmt.Println(connErr)
        return
    }

    data, dataErr := ioutil.ReadFile("/Users/home/Downloads/dataset/citylots.json")
    if dataErr != nil {
        fmt.Println(dataErr)
        return
    }

    var jsonData map[string]interface{}
    unmarshalErr := json.Unmarshal(data, &jsonData)
    if unmarshalErr != nil {
        fmt.Println(unmarshalErr)
        return
    }

    val := reflect.ValueOf(jsonData["features"])
    for i := 0; i < val.Len(); i++ {
        _, insertErr := r.DB("tootle").Table("citylots").Insert(val.Index(i).Interface()).Run(conn)
        if insertErr != nil {
            fmt.Println(insertErr)
            return
        }
    }
}
it ends with following Error
dial tcp: lookup localhost: no such host
Nick Stogner
@nstogner
I am trying to create a REST api based by rehtinkdb.... On a POST request where the doc already exists I would like to return a 409-Conflict response. I am not seeing an easy way of differentiating between errors for r.Table("...").Insert(...).RunWrite(...)
William McGann
@tehbilly
Does WriteResponse contain information you could use? Should contain number of inserts, updates, etc.
Nick Stogner
@nstogner
So I can look at the number of docs inserted... but how do I determine between an Internal-Server-Error and a Conflict?
Because if I have conflict set to "error" then the err wont be nil.... And I cant determine the failure cause
consider this code:
result, err := r.Table(Table).Insert(org).RunWrite(h.session) if err != nil { return httperr.New("could not insert org: "+err.Error(), http.StatusInternalServerError) } if result.Inserted == 0 { return httperr.New("organization already exists", http.StatusConflict) }
whoops that didnt look pretty
in this code, the Conflict portion will never be reached b/c the error is non-nil... but if i put reverse the checking... I might return a 409-Conflict when I should have returned a 500- internal-server-error
William McGann
@tehbilly
Hrm, gonna have to think on that for a few. Plus i have a three year old asleep on me right now.
But I am pondering!
Nick Stogner
@nstogner
haha thanks!
William McGann
@tehbilly
Silly question, is the response nil when the err is not?
Nick Stogner
@nstogner
no the response always is non-nil no matter what happens with the err
William McGann
@tehbilly
Sorry, it's been a heck of a day. Central VA, so tornados and blah. Anyways, if there's an error and a response, can use the counts to see if anything was changed iirc. Or, on failure, do another query to see what's there. Should tell you if there's an error between app and db or the error was due to it existing already
On a side note, freaking tornadoes in Virginia. Eesh
Nick Stogner
@nstogner
Yeah the tornadoes came thru NC also...
So it seems to me like there should be an explicit way of determining if a conflict has caused the insert to fail...
The only way I see how to check for a conflict is to parse the error message:
Duplicate primary key id:
Nick Stogner
@nstogner
^^ Wouldn't returning a specific error value from the RunWrite() method or in the WriteResponse be the appropriate way of determining this?
Nick Stogner
@nstogner
I went ahead an opened an issue
William McGann
@tehbilly
I think typed errors would be fantastic, doing a type switch to handle these would be much clearer
SamuelRamond
@SamuelRamond
Hi, just a little message to thank you for the gorethink driver it is awesome :+1:
Daniel Cannon
@dancannon
Thanks @SamuelRamond!