Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for already existing instances.
- Loading branch information
1 parent
71713ad
commit a496095
Showing
3 changed files
with
49 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Now we'll see how Iorm operates with existing tables. | ||
doRelativeFile("../iorm/Iorm.io") | ||
# We use the same models as in `basic.io`. | ||
session := Iorm Session withSQLite("./existing.sqlite") | ||
|
||
Author := Iorm Model with(session) setup( | ||
setTableName("authors") | ||
newField("name", Iorm VarcharField clone setLength(50)) | ||
newField("info", Iorm TextField clone) | ||
) | ||
# No `Author create` ... | ||
|
||
Book := Iorm Model with(session) setup( | ||
setTableName("books") | ||
newField("author", Iorm ForeignKeyField with(Author)) | ||
newField("title", Iorm VarcharField clone setLength(50)) | ||
) | ||
# ... and no `Book create` - they're already existing! | ||
|
||
# Now do a query | ||
max_goldt := Author objects filter(name == "Max Goldt") at(0) | ||
max_goldt info println |
Binary file not shown.