README.rdoc in swift-0.10.0 vs README.rdoc in swift-0.11.0
- old
+ new
@@ -119,16 +119,16 @@
# Alter attributes and update.
user.name = 'Apple Arthurton'
user.update
# Destroy
- user.destroy
+ user.delete
=== Conditions SQL syntax.
-SQL is easy and most people know it so Swift ORM provides a simple symbol like syntax to convert resource
-names to field names.
+SQL is easy and most people know it so Swift ORM provides simple #to_s
+attribute to field name typecasting.
class User < Swift::Scheme
store :users
attribute :id, Swift::Type::Integer, serial: true, key: true
attribute :age, Swift::Type::Integer, field: 'ega'
@@ -136,11 +136,14 @@
attribute :email, Swift::Type::String, field: 'liame'
end # User
# Convert :name and :age to fields.
# select * from users where eman like '%Arthurton' and ega > 20
- users = User.all(':name like ? and :age > ?', '%Arthurton', 20)
+ users = User.execute(
+ %Q{select * from #{User} where #{User.name} like ? and #{User.age} > ?},
+ '%Arthurton', 20
+ )
=== Identity Map
Swift comes with a simple identity map. Just require it after you load swift.
@@ -160,12 +163,13 @@
User.migrate!
# Create
User.create name: 'James Arthurton', email: 'james@arthurton.local' # => User
- User.first(':name = ?', 'James Arthurton')
- User.first(':name = ?', 'James Arthurton') # Gets same object reference
+ find_user = User.prepare(%Q{select * from #{User} where #{User.name = ?})
+ find_user.execute('James Arthurton')
+ find_user.execute('James Arthurton') # Gets same object reference
=== Bulk inserts
Swift comes with adapter level support for bulk inserts for MySQL and PostgreSQL. This
is usually very fast (~5-10x faster) than regular prepared insert statements for larger
@@ -263,10 +267,9 @@
== TODO
* More tests.
* Assertions for dumb stuff.
-* Abstract interface for other adapters? Move dbic++ to Swift::DBI::(Adapter, Pool, Result, Statment etc.)
== Contributing
Go nuts! There is no style guide and I do not care if you write tests or comment code. If you write something neat just
send a pull request, tweet, email or yell it at me line by line in person.