4 ms·
I can't imagine using RethinkDB until the query language ensures type safety. The article touts about SQL being full of strings, but ironically there are fully
by Ciantic 12y ago
I can't imagine using RethinkDB until the query language ensures type safety. The article touts about SQL being full of strings, but ironically there are fully typed query builders for SQL but not for RethinkDB. All DB tables has schema even though it's not listed anywhere, and schemaless databases can't have fully typed query language either.
- coffeemug 12y agoMany core RethinkDB developers are huge fans of type safety. Check out the RethinkDB Haskell driver (https://github.com/atnnn/haskell-rethinkdb https://github.com/atnnn/haskell-rethinkdb), and the .NET driver (https://github.com/mfenniak/rethinkdb-net https://github.com/mfenniak/rethinkdb-net). ReQL works really nicely with type safety (and will work even better when we let people declare optional schemas).
- wereHamster 12y agoCheck out my Haskell driver (https://github.com/wereHamster/rethinkdb-client-driver https://github.com/wereHamster/rethinkdb-client-driver). I think think the first paragraph of the readme describes the differences between my driver and atnnn's quite nicely: > It differs from the other driver (rethinkdb) in that it uses advanced Haskell magic to properly type the terms, queries and responses. For example the driver knows that this query returns a number, and tries to parse it as such: call2 (lift (+)) (lift 1) (lift 2) Here are a few more examples from my application: -- | The primary key in all our documents is the default "id". primaryKeyField :: Text primaryKeyField = "id" -- | Expression which represents the primary key field. primaryKeyFieldE :: Exp Text primaryKeyFieldE = lift primaryKeyField -- | Expression which represents the value of a field inside of an Object. objectFieldE :: (IsDatum a) => Text -> Exp Object -> Exp a objectFieldE field obj = GetField (lift field) obj -- | True if the object field matches the given value. objectFieldEqE :: (ToDatum a) => Text -> a -> Exp Object -> Exp Bool objectFieldEqE field value obj = Eq (objectFieldE field obj :: Exp Datum) (lift $ toDatum value) -- | True if the object's primary key matches the given string. primaryKeyEqE :: Text -> Exp Object -> Exp Bool primaryKeyEqE = objectFieldEqE primaryKeyField My driver doesn't include all commands of the query language, just those which I need in my product. And I haven't tested it with RethinkDB 2.0 yet.
- coffeemug 12y agoOh neat, thanks for pointing me to this!
- pka 12y agoStill, you are supplying the record fields to match on as T.Text. Check out [1] for a type-safer approach. I've been working on a typed expression builder for just this purpose, but due to lack of time haven't been able to finish it yet [2]. [1] http://hackage.haskell.org/package/structured-mongoDB-0.3 http://hackage.haskell.org/package/structured-mongoDB-0.3 [2] https://github.com/pkamenarsky/typesafe-query https://github.com/pkamenarsky/typesafe-query
- spopejoy 12y agoIs there any interest in blessing the Haskell driver as "official"?
- neumino 12y agoThinky can strictly enforce types.