Created
December 28, 2013 08:50
-
-
Save rikkimax/8157454 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module main; | |
import orm; | |
@tableName("Books") | |
class Book { | |
@id | |
@name("id") | |
string isbn; | |
@defaultValue("0") | |
ubyte edition; | |
void t() {} | |
mixin OrmModel!Book; | |
} | |
void main() { | |
Book.databaseConnection = DbConnection(DbType.Memory); | |
Book book = new Book; | |
book.isbn = "978-0-300-14424-6"; | |
book.save(); | |
assert(Book.find(book.isbn) != null); | |
assert(Book.find(book.isbn).length == 1); | |
assert(Book.find(book.isbn)[0].isbn == book.isbn); | |
assert(Book.findOne(book.isbn) !is null); | |
assert(Book.findOne(book.isbn).isbn == book.isbn); | |
assert(Book.findAll() !is null); | |
assert(Book.findAll().length == 1); | |
assert(Book.findAll()[0].isbn == book.isbn); | |
book.remove(); | |
assert(Book.findAll() is null); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment