supabase_api 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +72 -7
- data/lib/supabase_api/version.rb +1 -1
- data/supabase_api.gemspec +0 -4
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84f7e5cb75c6780f9e5d92c3754ba8bc47a4025435138c15a3eca2277bf94c0b
|
4
|
+
data.tar.gz: 3e8dd8a4d6660f151ad4e710a6b2deddc00ffa053246a97936473f13dd373b2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29bada7921d062dd522ceb7859c846649859c9032e571914af230275c1f109cdd712f2121a920d82cb8ccc56131f10340486b83c2d97e5a0387a982634555796
|
7
|
+
data.tar.gz: c265459ec9dae8192f9637a6c80711fc5966aa6a55880b9a1132598b266fa5dd6ae35d1209ad933bf26498f8ace7419a964af5157ed707e83d90bd6cdaa878c0
|
data/README.md
CHANGED
@@ -1,22 +1,87 @@
|
|
1
1
|
# SupabaseApi
|
2
2
|
|
3
|
-
|
3
|
+
Hi, this is a Ruby wrapper to access your Supabase tables via REST API in a manner similar to ActiveRecord model.
|
4
4
|
|
5
|
-
|
5
|
+
DISCLAIMER: This is not an official Ruby SDK.
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
9
|
Install the gem and add to the application's Gemfile by executing:
|
10
10
|
|
11
|
-
|
11
|
+
```bash
|
12
|
+
$ bundle add supabase_api
|
13
|
+
```
|
12
14
|
|
13
15
|
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
16
|
|
15
|
-
|
17
|
+
```bash
|
18
|
+
$ gem install supabase_api
|
19
|
+
```
|
16
20
|
|
17
21
|
## Usage
|
18
22
|
|
19
|
-
|
23
|
+
|
24
|
+
### Setup
|
25
|
+
Run these commands on the config or initializer file.
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# setups
|
29
|
+
require 'supabase_api' # if not using Rails
|
30
|
+
SupabaseApi::Sample.base_url = 'https://yourrandomapisubdomain.supabase.co'
|
31
|
+
SupabaseApi::Sample.api_key = 'veryrandomlongstring'
|
32
|
+
```
|
33
|
+
|
34
|
+
### With Rails
|
35
|
+
Create a ruby PORO class for your Supabase tables and inherit from the `SupabaseApi::Record` class.
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
class Book < SupabaseApi::Record
|
39
|
+
def self.table_name
|
40
|
+
# put the name of the table you want to connect with from Supabase
|
41
|
+
'books' # or 'Books', whatever you fancy
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
Then after that you can access your Supabase table just like a `ActiveRecord`-backed models.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
book_id_in_supabase = 100
|
50
|
+
Book.find(book_id_in_supabase)
|
51
|
+
|
52
|
+
# The line below will yield the same like above but will not raise any exception
|
53
|
+
book = Book.find_by_id(book_id_in_supabase)
|
54
|
+
|
55
|
+
# Assuming the books table has 'status' string column
|
56
|
+
book.status = 'archived'
|
57
|
+
book.save
|
58
|
+
|
59
|
+
# If you want to create a new book record
|
60
|
+
new_book = Book.new(
|
61
|
+
name: 'New Book',
|
62
|
+
status: 'pending'
|
63
|
+
)
|
64
|
+
new_book.save
|
65
|
+
|
66
|
+
# or
|
67
|
+
book = Book.create(
|
68
|
+
name: 'New Book',
|
69
|
+
status: 'pending'
|
70
|
+
)
|
71
|
+
book.id # => 100
|
72
|
+
|
73
|
+
# In case you regret creating it, you can delete the record
|
74
|
+
book.destroy
|
75
|
+
Book.find(100) # will raise an exception SupabaseApi::RecordNotFound
|
76
|
+
```
|
77
|
+
|
78
|
+
## TODO List
|
79
|
+
- add pagination.
|
80
|
+
- add command `.where` for the Record class to be able to query the table.
|
81
|
+
- add command `.update` for the Record instance.
|
82
|
+
- add command `#update` for the Record class to have multiple upserts.
|
83
|
+
- add more graceful and robust error handler.
|
84
|
+
|
20
85
|
|
21
86
|
## Development
|
22
87
|
|
@@ -26,7 +91,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
26
91
|
|
27
92
|
## Contributing
|
28
93
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/galliani/supabase_api. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/galliani/supabase_api/blob/master/CODE_OF_CONDUCT.md).
|
30
95
|
|
31
96
|
## License
|
32
97
|
|
@@ -34,4 +99,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
34
99
|
|
35
100
|
## Code of Conduct
|
36
101
|
|
37
|
-
Everyone interacting in the SupabaseApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
102
|
+
Everyone interacting in the SupabaseApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/galliani/supabase_api/blob/master/CODE_OF_CONDUCT.md).
|
data/lib/supabase_api/version.rb
CHANGED
data/supabase_api.gemspec
CHANGED
@@ -6,7 +6,6 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = "supabase_api"
|
7
7
|
spec.version = SupabaseApi::VERSION
|
8
8
|
spec.authors = ["Galih Muhammad"]
|
9
|
-
spec.email = ["galih.rubyist@gmail.com"]
|
10
9
|
|
11
10
|
spec.summary = "A ruby client for Supabase tables to be consumed as ruby class via the REST API"
|
12
11
|
spec.homepage = "https://github.com/galliani/supabase_api"
|
@@ -32,7 +31,4 @@ Gem::Specification.new do |spec|
|
|
32
31
|
|
33
32
|
# Uncomment to register a new dependency of your gem
|
34
33
|
spec.add_dependency "httparty"
|
35
|
-
|
36
|
-
# For more information and examples about making a new gem, check out our
|
37
|
-
# guide at: https://bundler.io/guides/creating_gem.html
|
38
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supabase_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Galih Muhammad
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -26,7 +26,6 @@ dependencies:
|
|
26
26
|
version: '0'
|
27
27
|
description:
|
28
28
|
email:
|
29
|
-
- galih.rubyist@gmail.com
|
30
29
|
executables: []
|
31
30
|
extensions: []
|
32
31
|
extra_rdoc_files: []
|