3 Data Object Persistence
procedure
(make-data-object db-connection data-class primary-key) → (data-object?) db-connection : connection? data-class : data-class? primary-key : (or/c identifier? (list of identifier?))
procedure
(save-data-object db-connection data-object) → (void?) db-connection : connection? data-object : data-object?
procedure
(insert-data-object db-connection data-object) → (void?) db-connection : connection? data-object : data-object?
procedure
(update-data-object db-connection data-object) → (void?) db-connection : connection? data-object : data-object?
procedure
(delete-data-object db-connection data-object) → (void?) db-connection : connection? data-object : data-object?
The optional #:print? keyword if true, will return only the SQL generated from the RQL. This is useful for debugging.
The optional #:prepare? keyword if true, will force the SQL statement generated to not be cached as a prepared statement. This is useful for RQL that may have variable inputs, such a list in an RQL in cause.
The join clauses and and where clauses use RQL defined below. Optionally a SQL string may be used rather than RQL. This may be done in situations where some advanced SQL feature needs to be used that currently cannot be coded in RQL.
procedure
(select-data-objects db-connection data-class [ print-kw prepare-kw] join-clause ... where-clause rest ...) → (listof data-object?) db-connection : connection? data-class : data-class?
print-kw :
= #:print? (or/c #t #f)
prepare-kw :
= #:prepare? (or/c #t #f) join-clause : any/c where-clause : any/c rest : any/c
The optional #:print? keyword if true, will return only the SQL generated from the RQL. This is useful for debugging.
The optional #:prepare? keyword if true, will force the SQL statement generated to not be cached as a prepared statement. This is useful for RQL that may have variable inputs, such a list in an RQL in cause.
(select-data-objects con address% "join person p on person-id = p.id \ |
where lastname in (select lastname from employee where active = 1)") |
procedure
→ (or/c 'new 'loaded 'saved 'deleted 'deserialized) data-object : data-object?
'new: the state of a data object that has been created but never stored in the database;
'loaded: the state of a data object that has been loaded from the database;
'saved: the state of a data object that has been saved to the database after being either newly created or loaded from the database;
'deleted: the state of a data object that has been deleted from the database;
'deserialized: the state of a data object that has been deserialized from a JSON or XML expression.
procedure
id : symbol? data-object : data-object?
procedure
(set-column! id data-object value) → (void?)
id : symbol? data-object : data-object? value : any/c
procedure
id : symbol? data-object : data-object?