README.md in fmrest-0.14.0 vs README.md in fmrest-0.15.0
- old
+ new
@@ -52,26 +52,41 @@
username: "…",
password: "…"
}
# Mapped attributes
- attributes name: "Bee Name", age: "Bee Age"
+ attributes name: "Bee Name", age: "Bee Age", created_on: "Created On"
- # Portals
- has_portal :flowers
+ # Portal associations
+ has_portal :tasks
- # File container
+ # File containers
container :photo, field_name: "Bee Photo"
+
+ # Scopes
+ scope :can_legally_fly, -> { query(age: ">18") }
+
+ # Client-side validations
+ validates :name, presence: true
+
+ # Callbacks
+ before_save :set_created_on
+
+ private
+
+ def set_created_on
+ self.created_on = Date.today
+ end
end
# Find a record by id
bee = Honeybee.find(9)
bee.name = "Hutch"
# Add a new record to portal
-bee.flowers.build(name: "Daisy")
+bee.tasks.build(urgency: "Today")
bee.save
```
### Barebones connection example (without ORM)
@@ -127,13 +142,13 @@
### Full list of available options
Option | Description | Format | Default
--------------------|--------------------------------------------|-----------------------------|--------
`:host` | Hostname with optional port, e.g. `"example.com:9000"` | String | None
-`:database` | | String | None
-`:username` | | String | None
-`:password` | | String | None
+`:database` | The name of the database to connect to | String | None
+`:username` | A Data API-ready account | String | None
+`:password` | Your password | String | None
`:account_name` | Alias of `:username` | String | None
`:ssl` | SSL options to be forwarded to Faraday | Faraday SSL options | None
`:proxy` | Proxy options to be forwarded to Faraday | Faraday proxy options | None
`:log` | Log JSON responses to STDOUT | Boolean | `false`
`:coerce_dates` | See section on [date fields](#date-fields-and-timezones) | Boolean \| `:hybrid` \| `:full` | `false`
@@ -286,11 +301,12 @@
class Honeybee < FmRest::Layout
layout "Honeybees Web"
end
```
-Alternatively, you can set the layout name in the class definition line:
+Alternatively, if you're inheriting from `FmRest::Layout` directly you can set
+the layout name in the class definition line:
```ruby
class Honeybee < FmRest::Layout("Honeybees Web")
```
@@ -386,11 +402,11 @@
### Query API
Since Spyke is API-agnostic it only provides a wide-purpose `.where` method for
passing arbitrary parameters to the REST backend. fmrest-ruby however is well
aware of its backend API, so it extends Spkye models with a bunch of useful
-querying methods: `.query`, `.limit`, `.offset`, `.sort`, `.portal`, `.script`,
-etc.
+querying methods: `.query`, `.match`, `.omit`, `.limit`, `.offset`, `.sort`,
+`.portal`, `.script`, etc.
See the [main document on querying](docs/Querying.md) for detailed information
on the query API methods.
### Finding records in batches