Skip to content

Instantly share code, notes, and snippets.

@rikkimax
Created December 28, 2013 08:50
Show Gist options
  • Save rikkimax/8157454 to your computer and use it in GitHub Desktop.
Save rikkimax/8157454 to your computer and use it in GitHub Desktop.
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