README.rdoc in swift-0.4.3 vs README.rdoc in swift-0.5.0

- old
+ new

@@ -19,10 +19,11 @@ * Multiple databases. * Prepared statements. * Bind values. * Transactions and named save points. * EventMachine asynchronous interface. +* IdentityMap. * Migrations. == Synopsis === DB @@ -37,11 +38,11 @@ db.execute('drop table if exists users') db.execute('create table users(id serial, name text, email text)') # Save points are supported. db.transaction :named_save_point do - st = db.prepare('insert into users (name, email) values (?, ?)') + st = db.prepare('insert into users (name, email) values (?, ?) returning id') puts st.execute('Apple Arthurton', 'apple@arthurton.local').insert_id puts st.execute('Benny Arthurton', 'benny@arthurton.local').insert_id end # Block result iteration. @@ -58,10 +59,11 @@ Rudimentary object mapping. Provides a definition to the db methods for prepared (and cached) statements plus native primitive Ruby type conversion. require 'swift' + require 'swift/migrations' Swift.trace true # Debugging. Swift.setup :default, Swift::DB::Postgres, db: 'swift' class User < Swift::Scheme @@ -90,10 +92,11 @@ === Scheme CRUD Scheme/relation level helpers. require 'swift' + require 'swift/migrations' Swift.trace true # Debugging. Swift.setup :default, Swift::DB::Postgres, db: 'swift' class User < Swift::Scheme @@ -143,23 +146,29 @@ Swift comes with a simple identity map. Just require it after you load swift. require 'swift' require 'swift/identity_map' + require 'swift/migrations' class User < Swift::Scheme store :users attribute :id, Swift::Type::Integer, serial: true, key: true attribute :age, Swift::Type::Integer, field: 'ega' attribute :name, Swift::Type::String, field: 'eman' attribute :email, Swift::Type::String, field: 'liame' end # User + # Migrate it. + 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 - === 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 sets of data. @@ -183,11 +192,10 @@ end You are not just limited to files - you can stream data from anywhere into MySQL and PostgreSQL directly without creating temporary files. - == Performance Swift prefers performance when it doesn't compromise the Ruby-ish interface. It's unfair to compare Swift to DataMapper and ActiveRecord which suffer under the weight of support for many more databases and legacy/alternative Ruby implementations. That said obviously if Swift were slower it would be redundant so benchmark code does exist in @@ -220,15 +228,15 @@ swift #create 0.180000 0.820000 1.000000 1.968757 27.35m swift #select 0.010000 0.070000 0.080000 0.130234 9.85m swift #update 0.250000 0.610000 0.860000 1.996165 29.35m swift #write 0.000000 0.100000 0.100000 0.167199 6.23m - == TODO * Tests. -* Assertions for dumb stuff. model < Model for methods in Adapter. -* Profile. +* Extension performance. Remove all repeated rb_intern() calls etc. +* 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.