A project defining DSL structures in Scala to work easily with the db4o database system. So far this is a little playground to use Scala to build a DSL for querying DB4O databases.
Code Sample
val db = Db4o.openFile(…)
// Run InitDB Application to create and fill the database.
// Use Native Queries
db filter((p:Person)=>p.firstName.equals(“Bart”))
// Use Native Queries with Comparators
db filter((p:Person)=>p.firstName.equals(“Bart”), (p1:Person, p2:Person)=> … ) // Needs to return Int [-1, 0, 1]
// Use SQL Style SODA Queries
db select Person.getClass where(’firstName := “Bart”) execute // Returns a ObjectSet[T]
Constraints
’fieldName := “value” // Equals
’fieldName !:= “value” // Not Equals
’fieldName | “value” // Starts With
’fieldName | “value” // Ends With
’fieldName ~ “value” // Like
’fieldName := 2 // Is
’fieldName !:= 2 // Is not
’fieldName > 2 // Greater
’fieldName < 2 // Smaller
’fieldName >= 2 // Greater or Is
’fieldName <= 2 // Smaller or Is