Code Monkey home page Code Monkey logo

t38c's People

Contributors

anusha-rapido avatar asmeikal avatar buddy-sandidge avatar caiodallaqua avatar dependabot-preview[bot] avatar dependabot[bot] avatar nimaghaedsharafi avatar shadowspore 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

Watchers

 avatar

t38c's Issues

Typo in Scan Query builder

Hello,

I have noticed a typo in t38c/scan_query_builder.go line 45 on "Cursor"

Thanks for the great work!

FSet is setting incorrect values in fields with very large values

Hello,

I ran into an with setting a field with a very large value using FSet resulting in an incorrect value set in Tile38. The issue appears to be caused by the rounding configured in the floatString function. I suspect a fix might be as simple as updating the formatFloat function to be something like this instead.

func formatFloat(v float64) string {
	return strconv.FormatFloat(v, 'f', 0, 64)
}

An example of a failure case:

_ = client.Keys.JSet("test", "example", "key", "value").Do()
_ = client.Keys.FSet("test", "example").Field("id", 123456789012345680).Do()

The code will result in example having a field id set to 123456789000000000 instead of the expected value 123456789012345680. However, manually setting the field in the cli does give the expected results. This can be sen in the Tile38 cli:

127.0.0.1:9851> GET test example WITHFIELDS
{"ok":true,"object":"{\"key\":\"value\"}","fields":{"id":123456789000000000},"elapsed":"19.377µs"}
127.0.0.1:9851> FSET test example id 123456789012345680
{"ok":true,"elapsed":"9.808µs"}
127.0.0.1:9851> GET test example WITHFIELDS
{"ok":true,"object":"{\"key\":\"value\"}","fields":{"id":123456789012345680},"elapsed":"20.699µs"}

I can create a PR if needed; let me know if I should do anything besides adding a test case to TestKeys.

"invalid number of arguments" when using Within.Get

Within.Get is incorrectly typed: according to the documentation it should build a query like WITHIN key1 GET key2 id, but the Get function only accepts one parameter objectID. All Within.Get queries fail with invalid number of arguments.

TTL errors when trying to unmarshal because tile38 returns a float not an int

After setting an object's expiration, calling TTL on the object causes an error:
json: cannot unmarshal number 0.174668 into Go struct field .ttl of type int

Calling TTL directly on the tile38-cli, looks like tile38 returns a float (instead of an int)
{"ok":true,"ttl":0.174668,"elapsed":"7.359µs"}

should be a super quick fix, something like this:

func (ks *Keys) TTL(key, objectID string) (float64, error) {
	var resp struct {
		TTL float64 `json:"ttl"`
	}

	err := ks.client.jExecute(&resp, "TTL", key, objectID)
	if err != nil {
		return -1, err
	}

	return resp.TTL, nil
}

How to get an Object back from a Nearby()

It feels a Nearby() request can only be formated as t38c.FormatPoints.

My data is a GeoJson feature like:

NEARBY restos POINT 37.400900 -79.178500 6000
{"ok":true,"objects":[{"id":"node/5807785416","object":{"type":"Feature","geometry":{"type":"Point","coordinates":[-79.2233665,37.3977684]},"id":"node/5807785416","properties":{"@id":"node/5807785416","amenity":"fast_food","brand":"Chipotle","brand:wikidata":"Q465751","brand:wikipedia":"en:Chipotle Mexican Grill","cuisine":"mexican","diet:vegan":"yes","diet:vegetarian":"yes","name":"Chipotle","official_name":"Chipotle Mexican Grill","opening_hours":"Mo-Su 10:45-22:00","outdoor_seating":"yes","takeaway":"yes","toilets:access":"customers"}}}],"count":1,"cursor":0,"elapsed":"211.209µs"}

So how can I do to use the other fields like brand out of a command like

	response, err := db.Search.Nearby("restos", lat, lon, 60000).
        Format(t38c.FormatPoints).  <----------------------------------------
	Do(context.TODO())

Thanks.

Testing

I use this for creating a point and mongodb. everything runs great. But now im testing and im unsure how to hit the keys.set.... part of the function. any pointers or examples would be fantastic

Expanding the scope of the builder field function

The function Field(name string, value float64) in the builders take a value as a float64. This makes the function not support strings, boolean and JSON. However, when building the command, the float64 is converts to a string using floatString(val float64) string. Should it then just take a string as a value like so Field(name string, value string) thus allowing for support of the missing types?

Document roam

Hi, thanks for this library. Is this possible to document the "roam" method for the geofence ?
The function signature is the following:
func (gf *Geofence) Roam(key, target, pattern string, meters int) GeofenceQueryBuilder
It is unclear to me if "pattern" corresponds to the pattern of the target collection, or of the key collection.
Is it possible to extend this query with a further "match" ?

Moreover, how to set/unset the "nodwell" keywork for this query?

Keys.Get output format

Hi,

I'm trying to retrieve a point in the Point output format. To do so, I tried to force a bit the Keys.Get without success, I found a way around but I am under the impression that this is not a good solution.

Tile.Keys.Set("fleet",  "truck1").Point(61.76543034, 37.67770367).Do()
// ==> [SET fleet truck1 POINT 61.76543034 37.67770367]: {"ok":true,"elapsed":"775.125µs"}

// This Fail
q, err := Tile.Keys.Get("fleet", "truck1"+" POINT", false)
// ==> [GET fleet truck1 POINT]: {"ok":false,"err":"id not found","elapsed":"35.208µs"}

// This works
q, err := Tile.Execute("GET", "fleet", "truck1", "POINT")
// ==> [GET fleet truck1 POINT]: {"ok":true,"point":{"lat":61.76543034,"lon":37.67770367},"elapsed":"373.291µs"}
resp := t38c.GetResponse{}
json.Unmarshal(q, &resp)

I can't get to understand why it failed when the two commands look exactly the same.

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.