Code Monkey home page Code Monkey logo

rethinkdb-go's Introduction

RethinkDB-go - RethinkDB Driver for Go

GitHub tag GoDoc Build status

Go driver for RethinkDB

RethinkDB-go Logo

Current version: v6.2.1 (RethinkDB v2.4)

Please note that this version of the driver only supports versions of RethinkDB using the v0.4 protocol (any versions of the driver older than RethinkDB 2.0 will not work).

If you need any help you can find me on the RethinkDB slack in the #gorethink channel.

Installation

go get gopkg.in/rethinkdb/rethinkdb-go.v6

Replace v6 with v5 or v4 to use previous versions.

Example

package rethinkdb_test

import (
	"fmt"
	"log"

	r "gopkg.in/rethinkdb/rethinkdb-go.v6"
)

func Example() {
	session, err := r.Connect(r.ConnectOpts{
		Address: url, // endpoint without http
	})
	if err != nil {
		log.Fatalln(err)
	}

	res, err := r.Expr("Hello World").Run(session)
	if err != nil {
		log.Fatalln(err)
	}

	var response string
	err = res.One(&response)
	if err != nil {
		log.Fatalln(err)
	}

	fmt.Println(response)

	// Output:
	// Hello World
}

Connection

Basic Connection

Setting up a basic connection with RethinkDB is simple:

func ExampleConnect() {
	var err error

	session, err = r.Connect(r.ConnectOpts{
		Address: url,
	})
	if err != nil {
		log.Fatalln(err.Error())
	}
}

See the documentation for a list of supported arguments to Connect().

Connection Pool

The driver uses a connection pool at all times, by default it creates and frees connections automatically. It's safe for concurrent use by multiple goroutines.

To configure the connection pool InitialCap, MaxOpen and Timeout can be specified during connection. If you wish to change the value of InitialCap or MaxOpen during runtime then the functions SetInitialPoolCap and SetMaxOpenConns can be used.

func ExampleConnect_connectionPool() {
	var err error

	session, err = r.Connect(r.ConnectOpts{
		Address:    url,
		InitialCap: 10,
		MaxOpen:    10,
	})
	if err != nil {
		log.Fatalln(err.Error())
	}
}

Connect to a cluster

To connect to a RethinkDB cluster which has multiple nodes you can use the following syntax. When connecting to a cluster with multiple nodes queries will be distributed between these nodes.

func ExampleConnect_cluster() {
	var err error

	session, err = r.Connect(r.ConnectOpts{
		Addresses: []string{url},
		//  Addresses: []string{url1, url2, url3, ...},
	})
	if err != nil {
		log.Fatalln(err.Error())
	}
}

When DiscoverHosts is true any nodes are added to the cluster after the initial connection then the new node will be added to the pool of available nodes used by RethinkDB-go. Unfortunately the canonical address of each server in the cluster MUST be set as otherwise clients will try to connect to the database nodes locally. For more information about how to set a RethinkDB servers canonical address set this page http://www.rethinkdb.com/docs/config-file/.

User Authentication

To login with a username and password you should first create a user, this can be done by writing to the users system table and then grant that user access to any tables or databases they need access to. This queries can also be executed in the RethinkDB admin console.

err := r.DB("rethinkdb").Table("users").Insert(map[string]string{
    "id": "john",
    "password": "p455w0rd",
}).Exec(session)
...
err = r.DB("blog").Table("posts").Grant("john", map[string]bool{
    "read": true,
    "write": true,
}).Exec(session)
...

Finally the username and password should be passed to Connect when creating your session, for example:

session, err := r.Connect(r.ConnectOpts{
    Address: "localhost:28015",
    Database: "blog",
    Username: "john",
    Password: "p455w0rd",
})

Please note that DiscoverHosts will not work with user authentication at this time due to the fact that RethinkDB restricts access to the required system tables.

Query Functions

This library is based on the official drivers so the code on the API page should require very few changes to work.

To view full documentation for the query functions check the API reference or GoDoc

Slice Expr Example

r.Expr([]interface{}{1, 2, 3, 4, 5}).Run(session)

Map Expr Example

r.Expr(map[string]interface{}{"a": 1, "b": 2, "c": 3}).Run(session)

Get Example

r.DB("database").Table("table").Get("GUID").Run(session)

Map Example (Func)

r.Expr([]interface{}{1, 2, 3, 4, 5}).Map(func (row Term) interface{} {
    return row.Add(1)
}).Run(session)

Map Example (Implicit)

r.Expr([]interface{}{1, 2, 3, 4, 5}).Map(r.Row.Add(1)).Run(session)

Between (Optional Args) Example

r.DB("database").Table("table").Between(1, 10, r.BetweenOpts{
    Index: "num",
    RightBound: "closed",
}).Run(session)

For any queries which use callbacks the function signature is important as your function needs to be a valid RethinkDB-go callback, you can see an example of this in the map example above. The simplified explanation is that all arguments must be of type r.Term, this is because of how the query is sent to the database (your callback is not actually executed in your Go application but encoded as JSON and executed by RethinkDB). The return argument can be anything you want it to be (as long as it is a valid return value for the current query) so it usually makes sense to return interface{}. Here is an example of a callback for the conflict callback of an insert operation:

r.Table("test").Insert(doc, r.InsertOpts{
    Conflict: func(id, oldDoc, newDoc r.Term) interface{} {
        return newDoc.Merge(map[string]interface{}{
            "count": oldDoc.Add(newDoc.Field("count")),
        })
    },
})

Optional Arguments

As shown above in the Between example optional arguments are passed to the function as a struct. Each function that has optional arguments as a related struct. This structs are named in the format FunctionNameOpts, for example BetweenOpts is the related struct for Between.

Cancelling queries

For query cancellation use Context argument at RunOpts. If Context is nil and ReadTimeout or WriteTimeout is not 0 from ConnectionOpts, Context will be formed by summation of these timeouts.

For unlimited timeouts for Changes() pass context.Background().

Results

Different result types are returned depending on what function is used to execute the query.

  • Run returns a cursor which can be used to view all rows returned.
  • RunWrite returns a WriteResponse and should be used for queries such as Insert, Update, etc...
  • Exec sends a query to the server and closes the connection immediately after reading the response from the database. If you do not wish to wait for the response then you can set the NoReply flag.

Example:

res, err := r.DB("database").Table("tablename").Get(key).Run(session)
if err != nil {
    // error
}
defer res.Close() // Always ensure you close the cursor to ensure connections are not leaked

Cursors have a number of methods available for accessing the query results

  • Next retrieves the next document from the result set, blocking if necessary.
  • All retrieves all documents from the result set into the provided slice.
  • One retrieves the first document from the result set.

Examples:

var row interface{}
for res.Next(&row) {
    // Do something with row
}
if res.Err() != nil {
    // error
}
var rows []interface{}
err := res.All(&rows)
if err != nil {
    // error
}
var row interface{}
err := res.One(&row)
if err == r.ErrEmptyResult {
    // row not found
}
if err != nil {
    // error
}

Encoding/Decoding

When passing structs to Expr(And functions that use Expr such as Insert, Update) the structs are encoded into a map before being sent to the server. Each exported field is added to the map unless

  • the field's tag is "-", or
  • the field is empty and its tag specifies the "omitempty" option.

Each fields default name in the map is the field name but can be specified in the struct field's tag value. The "rethinkdb" key in the struct field's tag value is the key name, followed by an optional comma and options. Examples:

// Field is ignored by this package.
Field int `rethinkdb:"-"`
// Field appears as key "myName".
Field int `rethinkdb:"myName"`
// Field appears as key "myName" and
// the field is omitted from the object if its value is empty,
// as defined above.
Field int `rethinkdb:"myName,omitempty"`
// Field appears as key "Field" (the default), but
// the field is skipped if empty.
// Note the leading comma.
Field int `rethinkdb:",omitempty"`
// When the tag name includes an index expression
// a compound field is created
Field1 int `rethinkdb:"myName[0]"`
Field2 int `rethinkdb:"myName[1]"`

NOTE: It is strongly recommended that struct tags are used to explicitly define the mapping between your Go type and how the data is stored by RethinkDB. This is especially important when using an Id field as by default RethinkDB will create a field named id as the primary key (note that the RethinkDB field is lowercase but the Go version starts with a capital letter).

When encoding maps with non-string keys the key values are automatically converted to strings where possible, however it is recommended that you use strings where possible (for example map[string]T).

If you wish to use the json tags for RethinkDB-go then you can call SetTags("rethinkdb", "json") when starting your program, this will cause RethinkDB-go to check for json tags after checking for rethinkdb tags. By default this feature is disabled. This function will also let you support any other tags, the driver will check for tags in the same order as the parameters.

NOTE: Old-style gorethink struct tags are supported but deprecated.

Pseudo-types

RethinkDB contains some special types which can be used to store special value types, currently supports are binary values, times and geometry data types. RethinkDB-go supports these data types natively however there are some gotchas:

  • Time types: To store times in RethinkDB with RethinkDB-go you must pass a time.Time value to your query, due to the way Go works type aliasing or embedding is not support here
  • Binary types: To store binary data pass a byte slice ([]byte) to your query
  • Geometry types: As Go does not include any built-in data structures for storing geometry data RethinkDB-go includes its own in the github.com/rethinkdb/rethinkdb-go/types package, Any of the types (Geometry, Point, Line and Lines) can be passed to a query to create a RethinkDB geometry type.

Compound Keys

RethinkDB unfortunately does not support compound primary keys using multiple fields however it does support compound keys using an array of values. For example if you wanted to create a compound key for a book where the key contained the author ID and book name then the ID might look like this ["author_id", "book name"]. Luckily RethinkDB-go allows you to easily manage these keys while keeping the fields separate in your structs. For example:

type Book struct {
  AuthorID string `rethinkdb:"id[0]"`
  Name     string `rethinkdb:"id[1]"`
}
// Creates the following document in RethinkDB
{"id": [AUTHORID, NAME]}

References

Sometimes you may want to use a Go struct that references a document in another table, instead of creating a new struct which is just used when writing to RethinkDB you can annotate your struct with the reference tag option. This will tell RethinkDB-go that when encoding your data it should "pluck" the ID field from the nested document and use that instead.

This is all quite complicated so hopefully this example should help. First lets assume you have two types Author and Book and you want to insert a new book into your database however you dont want to include the entire author struct in the books table. As you can see the Author field in the Book struct has some extra tags, firstly we have added the reference tag option which tells RethinkDB-go to pluck a field from the Author struct instead of inserting the whole author document. We also have the rethinkdb_ref tag which tells RethinkDB-go to look for the id field in the Author document, without this tag RethinkDB-go would instead look for the author_id field.

type Author struct {
    ID      string  `rethinkdb:"id,omitempty"`
    Name    string  `rethinkdb:"name"`
}

type Book struct {
    ID      string  `rethinkdb:"id,omitempty"`
    Title   string  `rethinkdb:"title"`
    Author  Author `rethinkdb:"author_id,reference" rethinkdb_ref:"id"`
}

The resulting data in RethinkDB should look something like this:

{
    "author_id": "author_1",
    "id":  "book_1",
    "title":  "The Hobbit"
}

If you wanted to read back the book with the author included then you could run the following RethinkDB-go query:

r.Table("books").Get("1").Merge(func(p r.Term) interface{} {
    return map[string]interface{}{
        "author_id": r.Table("authors").Get(p.Field("author_id")),
    }
}).Run(session)

You are also able to reference an array of documents, for example if each book stored multiple authors you could do the following:

type Book struct {
    ID       string  `rethinkdb:"id,omitempty"`
    Title    string  `rethinkdb:"title"`
    Authors  []Author `rethinkdb:"author_ids,reference" rethinkdb_ref:"id"`
}
{
    "author_ids": ["author_1", "author_2"],
    "id":  "book_1",
    "title":  "The Hobbit"
}

The query for reading the data back is slightly more complicated but is very similar:

r.Table("books").Get("book_1").Merge(func(p r.Term) interface{} {
    return map[string]interface{}{
        "author_ids": r.Table("authors").GetAll(r.Args(p.Field("author_ids"))).CoerceTo("array"),
    }
})

Custom Marshalers/Unmarshalers

Sometimes the default behaviour for converting Go types to and from ReQL is not desired, for these situations the driver allows you to implement both the Marshaler and Unmarshaler interfaces. These interfaces might look familiar if you are using to using the encoding/json package however instead of dealing with []byte the interfaces deal with interface{} values (which are later encoded by the encoding/json package when communicating with the database).

An good example of how to use these interfaces is in the types package, in this package the Point type is encoded as the GEOMETRY pseudo-type instead of a normal JSON object.

On the other side, you can implement external encode/decode functions with SetTypeEncoding function.

Logging

By default the driver logs are disabled however when enabled the driver will log errors when it fails to connect to the database. If you would like more verbose error logging you can call r.SetVerbose(true).

Alternatively if you wish to modify the logging behaviour you can modify the logger provided by github.com/sirupsen/logrus. For example the following code completely disable the logger:

// Enabled
r.Log.Out = os.Stderr
// Disabled
r.Log.Out = ioutil.Discard

Tracing

The driver supports opentracing-go. You can enable this feature by setting UseOpentracing to true in the ConnectOpts. Then driver will expect opentracing.Span in the RunOpts.Context and will start new child spans for queries. Also you need to configure tracer in your program by yourself.

The driver starts span for the whole query, from the first byte is sent to the cursor closed, and second-level span for each query for fetching data.

So you can trace how much time you program spends for RethinkDB queries.

Mocking

The driver includes the ability to mock queries meaning that you can test your code without needing to talk to a real RethinkDB cluster, this is perfect for ensuring that your application has high unit test coverage.

To write tests with mocking you should create an instance of Mock and then setup expectations using On and Return. Expectations allow you to define what results should be returned when a known query is executed, they are configured by passing the query term you want to mock to On and then the response and error to Return, if a non-nil error is passed to Return then any time that query is executed the error will be returned, if no error is passed then a cursor will be built using the value passed to Return. Once all your expectations have been created you should then execute you queries using the Mock instead of a Session.

Here is an example that shows how to mock a query that returns multiple rows and the resulting cursor can be used as normal.

func TestSomething(t *testing.T) {
	mock := r.NewMock()
	mock.On(r.Table("people")).Return([]interface{}{
		map[string]interface{}{"id": 1, "name": "John Smith"},
		map[string]interface{}{"id": 2, "name": "Jane Smith"},
	}, nil)

	cursor, err := r.Table("people").Run(mock)
	if err != nil {
		t.Errorf("err is: %v", err)
	}

	var rows []interface{}
	err = cursor.All(&rows)
	if err != nil {
		t.Errorf("err is: %v", err)
	}

	// Test result of rows

	mock.AssertExpectations(t)
}

If you want the cursor to block on some of the response values, you can pass in a value of type chan interface{} and the cursor will block until a value is available to read on the channel. Or you can pass in a function with signature func() interface{}: the cursor will call the function (which may block). Here is the example above adapted to use a channel.

func TestSomething(t *testing.T) {
	mock := r.NewMock()
	ch := make(chan []interface{})
	mock.On(r.Table("people")).Return(ch, nil)
	go func() {
		ch <- []interface{}{
			map[string]interface{}{"id": 1, "name": "John Smith"},
			map[string]interface{}{"id": 2, "name": "Jane Smith"},
		}
		ch <- []interface{}{map[string]interface{}{"id": 3, "name": "Jack Smith"}}
		close(ch)
	}()
	cursor, err := r.Table("people").Run(mock)
	if err != nil {
		t.Errorf("err is: %v", err)
	}

	var rows []interface{}
	err = cursor.All(&rows)
	if err != nil {
		t.Errorf("err is: %v", err)
	}

	// Test result of rows

	mock.AssertExpectations(t)
}

The mocking implementation is based on amazing https://github.com/stretchr/testify library, thanks to @stretchr for their awesome work!

Benchmarks

Everyone wants their project's benchmarks to be speedy. And while we know that RethinkDB and the RethinkDB-go driver are quite fast, our primary goal is for our benchmarks to be correct. They are designed to give you, the user, an accurate picture of writes per second (w/s). If you come up with a accurate test that meets this aim, submit a pull request please.

Thanks to @jaredfolkins for the contribution.

Type Value
Model Name MacBook Pro
Model Identifier MacBookPro11,3
Processor Name Intel Core i7
Processor Speed 2.3 GHz
Number of Processors 1
Total Number of Cores 4
L2 Cache (per Core) 256 KB
L3 Cache 6 MB
Memory 16 GB
BenchmarkBatch200RandomWrites                20                              557227775                     ns/op
BenchmarkBatch200RandomWritesParallel10      30                              354465417                     ns/op
BenchmarkBatch200SoftRandomWritesParallel10  100                             761639276                     ns/op
BenchmarkRandomWrites                        100                             10456580                      ns/op
BenchmarkRandomWritesParallel10              1000                            1614175                       ns/op
BenchmarkRandomSoftWrites                    3000                            589660                        ns/op
BenchmarkRandomSoftWritesParallel10          10000                           247588                        ns/op
BenchmarkSequentialWrites                    50                              24408285                      ns/op
BenchmarkSequentialWritesParallel10          1000                            1755373                       ns/op
BenchmarkSequentialSoftWrites                3000                            631211                        ns/op
BenchmarkSequentialSoftWritesParallel10      10000                           263481                        ns/op

Examples

Many functions have examples and are viewable in the godoc, alternatively view some more full features examples on the wiki.

Another good place to find examples are the tests, almost every term will have a couple of tests that demonstrate how they can be used.

Further reading

License

Copyright 2013 Daniel Cannon

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

rethinkdb-go's People

Contributors

abramovic avatar aleksi avatar anonx avatar bakape avatar baruch avatar cmogilko avatar codydwjones avatar cquon avatar dancannon avatar definitelycarter avatar elithrar avatar encryptio avatar ereyes01 avatar gabor-boros avatar jaredfolkins avatar jfbus avatar jhvst avatar jipperinbham avatar joaojeronimo avatar klaidliadon avatar lexaf avatar oliver006 avatar or-else avatar patdowney avatar r0l1 avatar radioact1ve avatar ragalie avatar rschmukler avatar thajeztah avatar tikiatua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rethinkdb-go's Issues

Issue Inserting Documents

I have a struct that has an Insert() method on it and am passing a populated reference to the struct to Insert. Inside Insert, I set some timestamps, generate a base64 encoded string for use as an "edit URL", and so on.

  • The program is panicking when it hits the doc, err := gorethink.Table("demo").Insert(l).RunWrite(conn) line.
  • I've ripped this out into a quick demo application and have replicated it. I'm running the latest head of gorethink and RethinkDB 1.10.1. Dan's example program works fine.
  • I'm using struct tags to ignore some fields but removing those didn't change anything.

Here's the relevant application code (the rest is just the struct definition and a quick main() setting the string fields to dummy values):

var conn *gorethink.Session

func (l *Listing) Insert() error {

    l.PostedDate = time.Now()
    l.EditedDate, l.RenewedDate = l.PostedDate, l.PostedDate
    l.Active = true

    editID, err := GetEditKey(32)
    if err != nil {
        return err
    }
    l.EditID = base64.URLEncoding.EncodeToString(editID)

    log.Printf("Prior to insert: %#v \n", l)

    doc, err := gorethink.Table("listings").Insert(l).RunWrite(conn)
    if err != nil {
        return err
    }

    if doc.Created != 1 {
        return errors.New("The document was not inserted correctly: " + l.Title + l.RepEmail)
    }

    l.Id = doc.GeneratedKeys[0]

    log.Printf("inserted id: %q", l.Id)
    return nil
}

func init() {
    conn, err := gorethink.Connect(map[string]interface{}{
        "address":  "localhost:28015",
        "database": "demo",
    })
    if err != nil {
        log.Fatalln(err.Error())
    }

    fmt.Printf("RethinkDB connection: %v\n", conn)
}

The program panics on line 78 โ€” the insert statement:

panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x0 pc=0x4fcf6]

goroutine 1 [running]:
runtime.panic(0x1b7860, 0x439319)
        /usr/local/Cellar/go/1.2rc3/libexec/src/pkg/runtime/panic.c:266 +0xb6
github.com/dancannon/gorethink.(*Session).nextToken(0x0, 0x0)
        /Users/matt/.go/src/github.com/dancannon/gorethink/session.go:159 +0x46
github.com/dancannon/gorethink.(*Session).startQuery(0x0, 0x1ec6d0, 0x6, 0x38, 0x0, ...)
        /Users/matt/.go/src/github.com/dancannon/gorethink/session.go:165 +0x5e
github.com/dancannon/gorethink.RqlTerm.Run(0x1ec6d0, 0x6, 0x38, 0x0, 0x0, ...)
        /Users/matt/.go/src/github.com/dancannon/gorethink/query.go:124 +0x104
github.com/dancannon/gorethink.RqlTerm.RunRow(0x1ec6d0, 0x6, 0x38, 0x0, 0x0, ...)
        /Users/matt/.go/src/github.com/dancannon/gorethink/query.go:142 +0x9f
github.com/dancannon/gorethink.RqlTerm.RunWrite(0x1ec6d0, 0x6, 0x38, 0x0, 0x0, ...)
        /Users/matt/.go/src/github.com/dancannon/gorethink/query.go:162 +0x92
main.(*Listing).Insert(0xc21004a6e0, 0xc21004a6e0, 0xc210085080)
        /Users/matt/Desktop/editurl.go:78 +0x2c2
main.main()
        /Users/matt/Desktop/editurl.go:57 +0x16e
exit status 2
``

query_time_test.go failures on TestTimeEpochTime/TestTimeTime

FAIL: query_time_test.go:15: RethinkSuite.TestTimeEpochTime

query_time_test.go:19:
  c.Assert(response.Equal(time.Date(1986, 11, 3, 0, 0, 0, 0, time.Local)), test.Equals, true)
... obtained bool = false
... expected bool = true

FAIL: query_time_test.go:8: RethinkSuite.TestTimeTime

query_time_test.go:12:
    c.Assert(response.Equal(time.Date(1986, 11, 3, 12, 30, 15, 0, time.Local)), test.Equals, true)
... obtained bool = false
... expected bool = true

Shouldn't Assert check time.UTC and not time.Local ?

RethinkDB 1.11

RethinkDB 1.11 was released today. Does gorethink pass all it's tests on 1.11? If so, maybe the version number in the README should be bumped to prevent confusion.

`Update` doesn't support Arrays

rdb.Table("test").Get(1).Update(map[string]interface{}{
        "list": [3]int{1, 2, 3},
    }).Exec(dbs)

... Panic: Cannot convert type '[3]int' to Datum (PC=0x414031)

How to do Upsert?

Insert a new record if "id" doesn't exist. If "id" exits update it.

Do we have this Upsert method?

More user friendly error message will be better

Blow is a error message I got,and with context in mind,I know some error message will be presented to me,but blow message still made me surprised.I think these are internal details of error,and if it can be "translated" into more user friendly format or style,it will save a lot of time to figure out what the real problem is.

gorethink.RqlRuntimeError{rqlResponseError:gorethink.rqlResponseError{response:(*ql2.Response)(0xc2000c8e10), term:gorethink.RqlTerm{name:"Filter", termType:39, data:interface {}(nil), args:[]gorethink.RqlTerm{gorethink.RqlTerm{name:"Table", termType:15, data:interface {}(nil), args:[]gorethink.RqlTerm{gorethink.RqlTerm{name:"", termType:1, data:"user", args:[]gorethink.RqlTerm(nil), optArgs:map[string]gorethink.RqlTerm(nil)}}, optArgs:map[string]gorethink.RqlTerm{}}, gorethink.RqlTerm{name:"{...}", termType:3, data:interface {}(nil), args:[]gorethink.RqlTerm(nil), optArgs:map[string]gorethink.RqlTerm{"email":gorethink.RqlTerm{name:"", termType:1, data:"Les Miserables", args:[]gorethink.RqlTerm(nil), optArgs:map[string]gorethink.RqlTerm(nil)}}}}, optArgs:map[string]gorethink.RqlTerm{}}}}

Struct `json` fields not serializing

Structs are being inserted into the database with the reflected field names, not the field names I define with json.

Example:
type CompanyResult struct {
Name string json:"name"
CategoryCode string json:"category_code"
Description string json:"description"
Permalink string json:"permalink"
}
_, err = re.Db("test").Table("company").Insert(companyResult).Run()

The database looks like this:
{"Permalink":"apple","Overview"...}

But when I scan this result and Marshal, the fields are serialized using json just fine. Thoughts?

Improve streaming logic

The official rethinkdb drivers have had their streaming logic improved and since this driver tries to match the features of the official driver as closely as possible GoRethink should also be updated.

For reference see rethinkdb/rethinkdb#1364

Add ReQL functions

  • Add all control ReQL functions
  • Add all database ReQL functions
  • Add all table ReQL functions
  • Add all writing ReQL functions
  • Add all selection ReQL functions
  • Add all join ReQL functions
  • Add all transformation ReQL functions
  • Add all aggregation ReQL functions
  • Add all document manipulation ReQL functions
  • Add all math ReQL functions
  • Add string ReQL function
  • Add all date ReQL functions

Bug: `nil` doesn't work in expressions

The following is a valid JS RQL expression:

r.expr(null).eq(null)  // returns true

However gorethink doesn't support that:

row, err := rdb.Expr(nil).Eq(nil).RunRow(dbs)

PANIC: user_test.go:110: UsersSuite.TestTrialValidate

... Panic: runtime error: invalid memory address or nil pointer dereference (PC=0x414031)

/usr/lib/go/src/pkg/runtime/panic.c:229
in panic
/usr/lib/go/src/pkg/runtime/panic.c:487
in panicstring
/usr/lib/go/src/pkg/runtime/os_linux.c:236
in sigpanic
/home/robert/.go/src/github.com/dancannon/gorethink/query_control.go:49
in expr
/home/robert/.go/src/github.com/dancannon/gorethink/query_control.go:18
in Expr
user_test.go:115
in UsersSuite.TestTrialValidate

Bug: `Update` doesn't work with `ChangeAt` and custom type

This is a short JS code which works correctly:

r.db('test').table('test').insert({id: 1, list: ['a','b','c']});
r.db('test').table('test').get(1).update(function(row){ return {
  list: row('list').changeAt(0, 'x') };});
r.db('test').table('test').get(1)

out:

{
    "id": 1 ,
    "list": [
        "x" ,
        "tata"
    ]
}

If we want to do a similar thing:

tab := rdb.Table("test")
tab.Delete().Exec(dbs)
err := tab.Insert(Map{"id": 1, "list": []interface{}{"a", "b"}}).Exec(dbs)
c.Assert(err, IsNil)

err = tab.Get(1).Update(func(r rdb.RqlTerm) interface{} {
    return map[string]interface{}{
        "list": r.Field("list").ChangeAt(0, "x"),
    }
}).Exec(dbs)
c.Assert(err, IsNil)

row, err := tab.Get(1).RunRow(dbs)
c.Assert(err, IsNil)
var res interface{}
err = row.Scan(&res)
c.Assert(err, IsNil)
fmt.Println(res)

out:

map[list:[x b] id:1]

however if we want to use custom type for map, then it wrongly decode object values:

type Map map[string]interface{}
...
err = tab.Get(1).Update(func(r rdb.RqlTerm) interface{} {
    return Map{    // HERE WE USE CUSTOM TYPE
        "list": r.Field("list").ChangeAt(0, "x"),
    }
}).Exec(dbs)
c.Assert(err, IsNil)

out:

map[list:map[] id:1]

Optional arguments

We need to decide on a format for doing optional arguments. As far as I can tell there are only a couple of solutions.

Firstly we could pass a map[string]interface{} to each function that can take optional arguments. For example:

r.Js("return 1;", map[string]interface{}{"timeout": 10}
r.Js("return 1;", map[string]interface{}{}

Another solution would be to keep the old approach of have a function for each optional parameter. One change I would make is to change the function to only change the optional parameters of the previous term instead of changing them for the entire query. For example:

r.Js("return 1;").Timeout(10)
r.Js("return 1;")

Any preferences to either choice or another option?

"duplicate enum registered: VersionDummy_Version" In init() chain

We're trying to migrate from rethinkgo to gorethink, but we can't even so much as get past the init() chain to use the library. Panic and trace follows.

panic: proto: duplicate enum registered: VersionDummy_Version

goroutine 1 [running]:
runtime.panic(0x3c3440, 0xc2100c8340)
/usr/local/Cellar/go/1.2/libexec/src/pkg/runtime/panic.c:266 +0xb6
code.google.com/p/goprotobuf/proto.RegisterEnum(0x5777d0, 0x14, 0xc21009bd50, 0xc21009bd80)
~/work/go/src/code.google.com/p/goprotobuf/proto/properties.go:646 +0xd2
github.com/dancannon/gorethink/ql2.initยท1()
~/work/go/src/github.com/dancannon/gorethink/ql2/ql2.pb.go:1023 +0x4e
github.com/dancannon/gorethink/ql2.init()
~/work/go/src/github.com/dancannon/gorethink/ql2/ql2.pb.go:1029 +0x71c
github.com/dancannon/gorethink.init()
~/work/go/src/github.com/dancannon/gorethink/utils.go:168 +0x80

Add type aliases for map[string]interface{} and []interface{}

I find map[string]interface{} and []interface{} pretty awkward and verbose.

Why not define some aliases (as mgo does with bson.M) ?

type M map[string]interface{}
type S []interface{}
Expr(map[string]interface{}{"a": 1, "c": 3}).Merge(map[string]interface{}{"b": 2})
Do([]interface{}{map[string]interface{}{"a": 1}, map[string]interface{}{"a": 2}, map[string]interface{}{"a": 3}})

would become

Expr(r.M{"a": 1, "c": 3}).Merge(r.M{"b": 2})
Do(r.S{r.M{"a": 1}, r.M{"a": 2}, r.M{"a": 3}})

Insert does not work with pointers

Insert supports inserting structs, but not pointer to structs :

o := Obj{A:1, B: "toto"}
res, err := r.Table("test").Insert(o).RunWrite(rs) // works
res, err := r.Table("test").Insert(&o).RunWrite(rs) // does not work

the error message is :

panic: Cannot convert type '*main.Obj' to Datum

goroutine 1 [running]:
github.com/dancannon/gorethink.RqlTerm.build(0x0, 0x0, 0x1, 0x123460, 0xc20009bb00, ...)
/server/src/github.com/dancannon/gorethink/query.go:27 +0x97

Use of map[string]interface{} or structs instead of ...interface{} for optArgs ?

Usage of optArgs, as currently implemented, is not easy to understand.

It currently is a list of argName, argValue :

t.Insert(doc, "durability", "soft")

Why not use a map or a struct ?

It would be easier to understand, and easier/faster to parse.

With maps :

type OptArgs map[string]interface{}
func (t RqlTerm) Insert(arg interface{}, optArgs OptArgs) RqlTerm

t.Insert(doc, r.OptArgs{"durability": "soft"})

With structs (my favorite, even if it means creating a new type for each call) :

type InsertOptions struct {
  Durability string
  [...]
}
func (t RqlTerm) Insert(arg interface{}, optArgs InsertOptions) RqlTerm

t.Insert(doc, r.InsertOptions{Durability: "soft"})

Bug: unable to decode Interface values

This does not work :

type Foo struct {
  FooBar interface{}
}
type Bar struct {
  Baz int
}
f := Foo{FooBar: &Bar{}}
row.Scan(&f)

Apparently, indirect in encoding/decode.go does not properly handle this case.

It looks like indirect is borrowed from encoding/json. If we compare source codes :

encoding/json/decode.go :

435 func (d *decodeState) object(v reflect.Value) {
436     // Check for unmarshaler.
437     unmarshaler, pv := d.indirect(v, false)
296 func (d *decodeState) indirect(v reflect.Value, decodingNull bool) (Unmarshaler, reflect.Value) {
...
308     if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) {

gorethink/encoding/decode.go :

func decodeObject(s *decodeState, dv reflect.Value, sv reflect.Value) (err error) {
    dv = indirect(dv)
func indirect(v reflect.Value) reflect.Value {
...
        if e.Kind() == reflect.Ptr && !e.IsNil() && e.Elem().Kind() == reflect.Ptr {

The decodingNull param is only used (= set to true) to be able to decode "null" into a pointer to a literal (literalStore, line 606).

We might want to add the decodeNull bool flag to indirect.

I can prepare a PR for this.

Failing unit test :

type Foo struct {
    FooBar interface{} `gorethink:"foobar"`
}
type Bar struct {
    Baz int `gorethink:"baz"`
}

func TestDecodeInterfaceValues(t *testing.T) {
    input := map[string]interface{}{
        "foobar": map[string]interface{}{
            "baz": 123,
        },
    }
    want := &Foo{FooBar: &Bar{Baz: 123}}

    out := &Foo{FooBar: &Bar{}}
    err := Decode(out, input)
    if err != nil {
        t.Errorf("got error %v, expected nil", err)
    }
    if !reflect.DeepEqual(out, want) {
        t.Errorf("got %q, want %q", out, want)
    }
}

No way to control field naming of an external struct

It would be nice to provide an alternate way (other than struct tagging) to control the Field name mapping behavior.

Defining an interface that the encoding package would use is a possible approach.

type RethinkFieldMapper interface {
    RethinkFieldMap() map[string]string
}

?

`rethinkdb:"..."` struct tags ignored ?

Some encoding tests fail and query_write_test.go writes the following in the DB :

{
    "Attrs": [
        {
            "Name":  "Attr 2" ,
            "Value":  "Value"
        }
    ] ,
    "Id": 0 ,
    "Name":  "map[string]interface{}ect 3" ,
    "id":  "becfe5aa-b538-4635-ae17-65b60aab30b1"
}

with

type object struct {
    Id    int64  `rethinkdb:"id,omitempty"`
    Name  string `rethinkdb:"name"`
    Attrs []attr
}

Converting a Contains Query from JS to Go

I'm attempting to convert some quick and dirty search RQL from JS to Go:

r.db('demo').table('listings').filter(function(row){return
                r.expr(['title','location','company']).contains(function(key){return
                  row(key).coerceTo('string').match('(?i)'+'developer')})}) 

So far I have:

docs, err := rethinkdb.Table("listings").Filter(func(row rethinkdb.RqlTerm) rethinkdb.RqlTerm {
        return rethinkdb.Expr([]string{"title", "location", "company", "term"}).Contains(func(key rethinkdb.RqlTerm) rethinkdb.RqlTerm {
            return rethinkdb.Row(key).CoerceTo("string").Match("(?i)"+s).Slice(lower, upper).Run(conn)
        })
    })

However I get (15 being the first line; 17 the last)

./search.go:15: assignment count mismatch: 2 = 1
./search.go:17: cannot call non-function gorethink.Row (type gorethink.RqlTerm)

What am I missing here?

PS: Is there an quick way to test whether a connection to RethinkDB is active? I'd like to test this when my application starts up so I can bail out if the DB is down. conn, err := rethinkdb.Connect(...) doesn't seem to return an error if the connection fails.

Improve row scan

Things to be improved:

  • Only use reflection when scanning into a struct
  • Cache as much reflection as possible
  • Simplify data type conversion.

Connection pooling

It makes sense to implement this in the driver, rather than forcing each user to implement it themselves.

We should learn from database/sql and make the pool size configurable from the start.

Add tests for ReQL functions

  • Add all control ReQL functions
  • Add all database ReQL functions
  • Add all table ReQL functions
  • Add all writing ReQL functions
  • Add all selection ReQL functions
  • Add all join ReQL functions
  • Add all transformation ReQL functions
  • Add all aggregation ReQL functions
  • Add all document manipulation ReQL functions
  • Add all math ReQL functions
  • Add string ReQL function
  • Add all date ReQL functions

[Proposal] Split `RqlTerm` into more reacher types

In first class rethinkdb drivers (js, python, ruby) we have have more reacher types then simple expression (RqlTerm):

  • singleRowSelection
  • selection
  • ....

We can slit RqlTerm into RqlTerm and SRqlTerm (simple/single RQL term) - this can help us construct RQL expressinos, because some of them are not valid, like:

row, err := r.Table("table").Get("key").Count().RunRow(s)
// err = gorethink: Expected type SEQUENCE but found SINGLE_SELECTION:

When RqlTerm.Get would return SRqlTerm then we can avoid such errors in runtime.

Maybe it is worth to introduce even more types?

  • Scalar -> is returned by expressions like Count, IsEmpty, ..

Inserts get truncated data at high concurrency

I'm playing around with the driver at runtime.GOMAXPROCS(8) and trying to insert 29k documents using this Zip JSON. After a while, the driver gives this error at random location and stop

gorethink: String `CALCASIEU` (truncated) contains NULL byte at offset 9. in:
r.Insert(r.Table("zips"), {City="CALCASIEU\x00", Loc=[-91.875149, 31.906412], Pop=124, State="LA"})

Although everything runs fine at runtime.GOMAXPROCS(4) and rethinkdb get to around 3k of inserts/sec. The sample code is here (http://play.golang.org/p/ye2BpuJzlE)

RunRow needs to differentiate between an error and no results

It is currently returning both an empty row and an error, but this makes it hard to discern between a real error (f.ex. connection lost) and just not getting any data. In the later case I prefer to just test for IsNil on the row and have err as nil.

Using RunWrite with TableCreate doesn't provide results.

When creating a table with RunWrite:

r.Db(dbName).TableCreate(tableName).RunWrite(session)

The results I get are:

{0 0 0 0 0 0 []  <nil> <nil>}

Even though the table is create just fine in the DB there is nothing in the results indicating it was created successfully. Could this be that WriteResponse doesn't have a Created filed?

Where I'm confused is that the docs for RunWrite state:

This function should be used if you are running a write query 
(such as Insert, Update, TableCreate, etc...)

Not sure if this is expected behavior or just a bug in the docs. I have no problem tackling this time permitting.

Example for Append()?

I'm trying to Append() to an embedded array like this:

row, err := r.Table("things").
    Get(thingId).
    Field("array").
    Append(map[string]string{"tag": "value"}).
    RunWrite(dbSession)

"array": [ ]    ->    "array": [ {"tag": "value"} ]

... it does not work; the array remains empty. What am I doing wrong?

ResultRows.IsNil() always return true before Next() is called?

rows, _ := r.Table("users").Run(conn)
fmt.Println(rows.IsNil())
for rows.Next() {
    var row interface{}
    err = rows.Scan(&row)
    fmt.Println(row)
    fmt.Println(rows.IsNil())
}
fmt.Println(rows.IsNil())

And the result:

true
map[id:2dabdea7-e179-4311-9d06-5292c0dd46ff name:user1]
false
...
false

Even the ResultRows actually has data, the first IsNil() call returns true, is this a little confusing?

Unable to check if Get() returns nothing

As with rethinkgo, Get() always returns a single row and does not provide any way of checking if a record exists.

row := r.Table(table).Get("missing key").RunRow(rs)
err := row.Scan(obj)
// err == nil, obj has default values

rows, err := r.Table(table).Get("missing key").Run(rs)
// err == nil
for rows.Next() { // returns true
    err := rows.Scan(obj)
    // err == nil, obj has default values
}

GetAll works :

rows, err := r.Table(table).GetAll("missing key").Run(rs)
// err == nil
for rows.Next() { // returns false
    err := rows.Scan(obj)
}

RethinkDB returns a single NULL datum on Get queries returning no result, and this null value is scanned to the object.

Proposition :

  • [BC break] ResultRow.Scan returns ErrNotFound on NULL datum (as works mgo for MongoDB in similar cases)
  • add func (*ResultRow) IsNull() (or IsEmpty()/IsNil())

The code would work as follows :

row := r.Table(table).Get("missing key").RunRow(rs)
err := row.Scan(obj)
// err == ErrNotFound

rows, err := r.Table(table).Get("missing key").Run(rs)
// err == nil
for rows.Next() && !rows.IsNull() { // true + false
    err := rows.Scan(obj)
}

If this is ok, I can prepare a PR.

[EDIT: replaced RunRow by Run on last piece of code]

Add code for requests/responses

  • Add tests for connection code
  • Add code for sending queries to the server
  • Add code for handling responses from the server
  • Add proper error handling including formatting of results/errors
  • Add ability to navigate through a response similar to the SQL drivers
  • Add ability to bind a response to a struct. Look into implementing rethink tags instead of using JSON
  • Add ability to encoding structs to be sent to the server

Connection pool scheduler.

By now if we limit a connection pool and we want to open a new connection above Pool.MaxActive we get ErrPoolExhausted error - "gorethink: connection pool exhausted".

It would be very desirable to have a scheduler for Pool. It will wait for a next released connection and pass it to a next waiting request.

Proposed objectives:

  • scheduler is plug-able
  • default scheduler:
    • use simple LIFO scheduling
    • supports time-outs

Helper functions

In my project I have implemented Scan, ScanAll, ScanFirst, Exists, ExistsMulti helper functions. Example usage:

var products []map[string]string
err = rdbu.ScanAll(tabProduct, &products, dbsession)
var user User
notNil, err = rdbu.Scan(tabUser.GetAllByIndex("email", "[email protected]"), &user, dbsession)

Scan* automatically reflects the destination type. Furthermore ScanAll asserts that destination is a pointer to slice.

It's easier to explain all of them in a code: https://gist.github.com/robert-zaremba/7115332
Each of this functions I found useful.

I can pull request them with a test suite.

[Bug] Decoding doesn't work for query with OrderBy & EqJoin

The case when it doesn't work is when we want to use OrderBy and EqJoin in the same query.
Below I'm presenting a test which proves that decoding doesn't work.

func (suite *DBSuite) TestOrderJoin(c *C) {
    type Map map[string]interface{}
    tab := rdb.Table("test")
    tab2 := rdb.Table("test2")
    var err error
    rdb.Db("test").TableDrop("test").Exec(dbs)
    err = rdb.Db("test").TableCreate("test").Exec(dbs)
    c.Assert(err, IsNil)
    rdb.Db("test").TableDrop("test2").Exec(dbs)
    err = rdb.Db("test").TableCreate("test2").Exec(dbs)
    c.Assert(err, IsNil)

    err = tab.Insert(Map{"S": "s1", "T": 2}).Exec(dbs)
    err = tab.Insert(Map{"S": "s1", "T": 1}).Exec(dbs)
    err = tab.Insert(Map{"S": "s1", "T": 3}).Exec(dbs)
    err = tab.Insert(Map{"S": "s2", "T": 3}).Exec(dbs)
    c.Assert(err, IsNil)

    err = tab2.Insert(Map{"id": "s1", "N": "Rob"}).Exec(dbs)
    err = tab2.Insert(Map{"id": "s2", "N": "Zar"}).Exec(dbs)
    c.Assert(err, IsNil)

    rows, err := tab.
        OrderBy("T").      // [1]
        EqJoin("S", tab2). // [2]
        Run(dbs)
    c.Assert(err, IsNil)

    var out []Map
    for rows.Next() {
        p := Map{}
        err = rows.Scan(&p)
        c.Assert(err, IsNil)  // ERROR: gorethink: cannot decode array into Go value of type main.Map
        out = append(out, p)
    }
    c.Check(len(out), Equals, 4, Commentf("%v", out))
}

When we comment out line [1] or [2] then everything works well.

In rethinkdb dataexplorer the query works and return right value (array of maps)

wercker not testing ./encoding ?

On my box,

  • go test ./... tests both [...]/rethinkdb and [...]/rethinkdb/encoding, and fails on the latter.
  • go test -gocheck.v=true -test.v=true ./... (used on wercker) does not test [...]/rethinkdb/encoding (which does not use gocheck)

Don't break name, keep rethinkgo.

This driver is based on Christopher Hesse's RethinkGo.
Is there any reason to break history and introduce new driver name and confuse community?

What I see is that this driver just continue development of rethinkgo.

How do I use an index with Filter?

I have been trying to figure out how to use an index with the Filter:

rows, err := r.Table(CensusTableName).GetAllByIndex("Name").Filter(map[string]interface{}{"Name": name}).OrderBy(rethink.Desc("Year")).Run(session)

I made sure the index has been created but still there is no performance advantage using an index. Do I have the wrong syntax?

Refactor Driver

Refactor https://github.com/christopherhesse/rethinkgo. If you have any ideas you want added please comment below and I will add it to the list.

Tasks

  • Add base query tree structure
  • Develop better debug printing of the query tree
  • Add handling for basic data types
  • Add handling for arrays
  • Add handling for objects
  • Add handling for functions
  • Add the Expr function (Important as it is used a lot internally)
  • Add ReQL functions ( #6 )
  • Add tests for all ReQL functions ( #7 )
  • Add code for handling requests and responses as well as encoding/decoding values to be sent/received ( #8 )
  • Add connection pooling ( #1 )
  • Add optional arguments functionality ( #4 )
  • Check for spelling errors/typos
  • Remove List and Obj
  • Add driver documentation + licence etc

Notes

  • There are currently some issues with scanning if the wrong type is passed. For example if the server returns a slice and the user scans in a map then the driver panics. It would be nice to catch this error
  • It might be worth trying to have set types for each function with anonymous function as arguments such as map

`CountFiltered` returns wrong response.

Either documentation is wrong or there is a bug in code.
The docs says:

Count the number of elements in the sequence. CountFiltered uses the argument passed to it to filter the results before counting.

I assume that CountFiltered is a shortcut for Filter and Count and it uses flexible argument type.

type DBMap map[string]interface{}

resp, err := rdb.Table("user").Insert(DBMap{"email": "[email protected]"}).RunWrite(dbs)
c.Assert(err, IsNil)
c.Assert(resp.Inserted, Equals, 1, Commentf("resp: %v", resp))

r := rdb.Table("user").Filter(DBMap{"email": "[email protected]"}).Count().RunRow(dbs)
c.Check(r.IsNil(), IsFalse)
var count float64
err = r.Scan(&count)
c.Assert(err, IsNil)
c.Check(count, Equals, 1.)

r = rdb.Table("user").CountFiltered(DBMap{"email": "[email protected]"}).RunRow(dbs)
c.Check(r.IsNil(), IsFalse)
err = r.Scan(&count)
c.Assert(err, IsNil)
c.Check(count, Equals, 1.) // FAIL: count = 0.

Add examples for each query

Chris did a fantastic job of this with http://godoc.org/github.com/christopherhesse/rethinkgo (every RQL operation has a basic example above it) and I think we could do a similarly fantastic job.

I'm opening an issue for this as a prompt for others to contribute/as a "to do" item to flesh out the documentation.

I plan to work on this proper once my schedule frees up mid November, but I'll be chipping away at this when I can as I move my (as yet unfinished!) side-project over to this driver.

How to use index with OrderBy?

Both of the following don't work:

OrderBy("index-name")
OrderBy(map[string]string{"index": "index-name"}) // Error: Unable to get quotes from DB gorethink: Expected type STRING but found OBJECT.

Where "index-name" is different then the name of each document fields.

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.