fauna / faunadb-ruby Goto Github PK
View Code? Open in Web Editor NEWRuby driver for FaunaDB
Home Page: https://fauna.com
License: Other
Ruby driver for FaunaDB
Home Page: https://fauna.com
License: Other
Now that Classes and Worlds are plain old objects we can drop some special cases.
It should be easy to bring Query methods into scope in order to eliminate the need to namespace them.
For instance, I'd like to be able to do this:
class Foo
include Fauna::Query
def createDB(dbName)
create(Ref.new('databases'), quote(name: dbName))
end
end
That's not possible without some hackery because the query methods are all module methods.
RestClient doesn't really buy us anything and it's underlying use of Net::HTTP is truly terrifying.
Right now the readme asks you to build it yourself.
in exponential form probably.
set.page vs set.eventPage doesn't make much sense. Can we get rid of the intermediate object and just act on the Set itself? Maybe put it in a specific mode?
Similar to field
, now that we have generalized constraints.
However, perhaps we should rethink how the gem exposes access to deeply nested fields. It doesn't correspond to the regular Rails/relational way very well.
Also applies to references
I suppose.
If someone puts values like secret
and observer
into the client, it might be convenient to have them gettable later. They are accessible in python but not documented. Should we make it official?
I don't think the query interface is fully fleshed out.
It might make more sense to exclusively support string interpolation rather than expect reified nested objects. Whatever is easier for the user to understand.
def test_invalid_response
# Response must be valid JSON
assert_raises ??? do
(stub_get 200, 'I like fine wine').get ''
end
# Response must have "resource"
assert_raises ??? do
(stub_get 200, '{"resoars": 1}').get ''
end
end
Instead of manipulating them directly.
They read like english, not C.
Desired behavior:
append([1,2,3], [4,5,6]) => [1,2,3,4,5,6]
prepend([4,5,6], [1,2,3]) => [1,2,3,4,5,6]
When you are paginating over a set that contains arrays, the pagination helper flattens those arrays too, so it ends up emitting [a1, b1, a2, b2,....] as opposed to [[a1, b1], [a2, b2], ....]
completely unverified at this point. related to #37
We should be wrapping all network calls to Fauna in a retries block like this:
with_retries(:max_tries => 3, :rescue => [Timeout::Error, Errno::ECONNRESET, Fauna::Connection::NetworkError], :max_sleep_seconds => 10) do
self.client.post params
end
This will give us more hope for fixing the concurrency issues under JRuby introduced by Typhoeus.
Degree of magic in the client does not inspire confidence. I think we can do better, in particular around the DDL manipulation and default fields in built-in records.
The first issue is in line 37 of 'fauna.rake'
class_name = ref[0..-8]
If you have a class ref like "classes/thisisatest", the the class_name will be "classes/this". Ought to be
class_name = [8..-1]
If the ref is long enough, when Dir.chdir(class_name)
is called on line 40, an additional 'classes' directory also is created.
Also, the Fauna.connection.get(class_name)
on line 43 ought to be changed to Fauna.connection.get(ref)
.
It's overly opinionated. Disable everything by default and only enable linters we find useful.
bundle exec rake rdoc
.doc/index.html
.#add
to go to doc/Fauna/Query.html#method-i-add
.Since FaunaDB API access relies on keys to switch perspectives, it should be easy to temporarily do so with a client. For example:
client = Fauna::Client.new(secret: SERVER_KEY)
user_token = client.query do
login ref('users/123'), password: 'sekrit'
end
user_client = client.with_secret(user_token[:secret])
user_client.query do
paginate match(ref('indexes/items_by_user'), ref('users/self'))
end
When creating multiple new resources using Fauna::Resource.new()
, the resulting Resource objects share the following attributes' instances between them:
constraints
data
references
Since they are the same instance, edits to one of the attributes will result in the change being applied to all resources created with Fauna::Resource.new()
.
For example, in the following code:
settings = Fauna::Resource.new('settings', :ref => 'settings/12345678', :email => '[email protected]')
user = Fauna::Resource.new('users', :ref => 'users/87654321')
settings.data['test'] = true
The following statements will all return true:
user.data['test'] == true
user.constraints.object_id == settings.constraints.object_id
user.data.object_id == settings.data.object_id
user.references.object_id == settings.references.object_id
It's not included in the exception message, so it's inconvenient to get to when a raised exception is printed out.
Fauna::Connection::NotFound makes it seem like it's a connection issue, rather than a 404 response.
Fauna::NotFound or Fauna::Resource::NotFound would be better.
It looks like a new publisher key is generated on each boot of a rails app. I've added a publisher_key setting to fauna.yml that can be used in lieu of the email/password credentials. Changes here: https://github.com/wam/fauna-ruby/compare/allow-publisher-key
Makes sense? If so I can open a pull request.
Possible issue: When using a publisher key, no root connection is established in the rails helper. Not sure if it's intended to be used elsewhere.
We need to let you set the valid time on a finder, as well as add CRUD for manipulating individual versions of resources.
And document .page and its friends.
In 1.3.1, the gemspec has two hardcoded references to Evan's filesystem:
s.cert_chain = ["/Users/eweaver/fauna/fauna-ruby/fauna-ruby.pem"]
...
s.signing_key = "/Users/eweaver/cloudburst/configuration/gem_certificates/gem-private_key.pem"
https://github.com/fauna/fauna-ruby/blob/master/fauna.gemspec#L10
https://github.com/fauna/fauna-ruby/blob/master/fauna.gemspec#L22
Bundler is complaining about it:
Errno::ENOENT: No such file or directory - /Users/eweaver/cloudburst/configuration/gem_certificates/gem-private_key.pem
An error occurred while installing fauna (1.3.1), and Bundler cannot continue.
Make sure that `gem install fauna -v '1.3.1'` succeeds before bundling.
Is there a workaround?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.