Wt: Wt::Dbo Namespace Reference

Wt 4.10.4

Loading...
Searching...
No Matches
Namespaces | Classes | Enumerations | Functions | Variables
Wt::Dbo Namespace Reference

Namespace for the Database Objects (Wt::Dbo). More...

## Namespaces
namespace | backend
| Namespace for Dbo backends.

## Classes
class | AbstractQuery
| An abstract dynamic database query. More...
class | Call
| A database call. More...
class | collection
| An STL container for iterating query results. More...
class | Dbo
| A base class for database objects. More...
class | dbo_default_traits
| Default traits for a class mapped with Wt::Dbo. More...
class | dbo_traits
| Traits for a class mapped with Wt::Dbo. More...
class | DirectBinding
class | DynamicBinding
class | Exception
| Exception base class for Wt::Dbo. More...
class | FieldInfo
| Description of a field. More...
class | FixedSqlConnectionPool
| A connection pool of fixed size. More...
class | ForeignKeyConstraint
| Type that indicates one or more foreign key constraints. More...
class | JsonSerializer
| An action to serialize objects to JSON. More...
class | NoUniqueResultException
| Exception thrown when a query unexpectedly finds a non-unique result. More...
class | ObjectNotFoundException
| Exception thrown when trying to load a non-existing object. More...
class | ptr
| A smart pointer for a database object. More...
class | Query
| A database query. More...
class | query_result_traits
| Traits class for result types. More...
class | QueryModel
| A Wt MVC Model to view/edit query results. More...
class | Session
| A database session. More...
class | sql_value_traits
| Traits class for value types. More...
class | SqlConnection
| Abstract base class for an SQL connection. More...
class | SqlConnectionPool
| Abstract base class for a SQL connection pool. More...
class | SqlStatement
| Abstract base class for a prepared SQL statement. More...
class | StaleObjectException
| Exception thrown when Wt::Dbo detects a concurrent modification More...
class | Transaction
| A database transaction. More...
class | weak_ptr
| A weak pointer for a database object. More...

## Enumerations
enum | RelationType { ManyToOne , ManyToMany }
| Type of an SQL relation. More...
enum class | FlushMode { Auto , Manual }
| Enumeration that indicates the flush mode. More...
enum class | SqlDateTimeType { Date , DateTime , Time }
| Enum that defines a date time type. More...
enum class | LimitQuery { Limit , RowsFromTo , Rownum , OffsetFetch , NotSupported }
| Enum that defines a limit query type. More...
enum | FieldFlags { SurrogateId = 0x1 , NaturalId = 0x2 , Version = 0x4 , Mutable = 0x8 , NeedsQuotes = 0x10 , ForeignKey = 0x20 , FirstDboField = 0x40 , LiteralJoinId = 0x80 , AuxId = 0x100 , AliasedName = 0x200 }
| Flags. More...

## Functions
ForeignKeyConstraint | operator| (ForeignKeyConstraint lhs, ForeignKeyConstraint rhs)
| Combines two constraints.
template<class Action , typename V >
void | id (Action &action, V &value, const std::string &name="id", int size=-1)
| Maps a natural primary key (id) field.
template<class Action , class C >
void | id (Action &action, ptr< C > &value, const std::string &name, ForeignKeyConstraint constraints, int size=-1)
| Maps a natural primary key (id) field that is a foreign key.
template<class Action , typename V >
void | field (Action &action, V &value, const std::string &name, int size=-1)
| Maps a database object field.
template<class Action , class C >
void | belongsTo (Action &action, ptr< C > &value, const std::string &name=std::string())
| Maps the "One"-side (foreign key) of a ManyToOne or OneToOne relation.
template<class Action , class C >
void | belongsTo (Action &action, ptr< C > &value, const std::string &name, ForeignKeyConstraint constraints)
| Maps the "One"-side (foreign key) of a ManyToOne or OneToOne relation.
template<class Action , class C >
void | belongsTo (Action &action, ptr< C > &value, ForeignKeyConstraint constraints)
| Maps the "One"-side (foreign key) of a ManyToOne or OneToOne relation.
template<class Action , class C >
void | hasOne (Action &action, weak_ptr< C > &value, const std::string &name=std::string())
| Maps the "One"-side of a OneToOne relation.
template<class Action , class C >
void | hasMany (Action &action, collection< ptr< C > > &value, RelationType type, const std::string &name=std::string())
| Maps the "Many"-side of a ManyToOne or ManyToMany relation.
template<class Action , class C >
void | hasMany (Action &action, collection< ptr< C > > &value, RelationType type, const std::string &name, const std::string &joinId, ForeignKeyConstraint constraints=(NotNull|OnDeleteCascade))
| Maps the "Many"-side of a ManyToMany relation.
template<typename C >
void | jsonSerialize (const C &c, std::ostream &out)
| Serialize the given object to the given ostream.
template<typename C >
void | jsonSerialize (const ptr< C > &c, std::ostream &out)
| Serialize the object pointed to by the given ptr to the given ostream.
template<typename C >
void | jsonSerialize (const std::vector< ptr< C > > &v, std::ostream &out)
| Serialize a vector of ptrs to the given ostream.
template<typename C >
void | jsonSerialize (const collection< C > &c, std::ostream &out)
| Serialize a collection of ptrs to the given ostream.
WTDBO_API void | setCustomLogger (const WLogSink &customLogger)
| Sets a custom logger to redirect all logging to.
void | logToWt ()
| Redirects all Dbo logging to Wt::log.
template<typename T , typename ... Args>
ptr< T > | make_ptr (Args &&...args)
| Make a new ptr.

## Variables
const ForeignKeyConstraint | NotNull
| A constraint that prevents a `null` ptr.
const ForeignKeyConstraint | OnUpdateCascade
| A constraint that cascades updates.
const ForeignKeyConstraint | OnUpdateSetNull
| A constraint that cascades updates.
const ForeignKeyConstraint | OnUpdateRestrict
| A constraint that restricts updates.
const ForeignKeyConstraint | OnDeleteCascade
| A constraint that cascades deletes.
const ForeignKeyConstraint | OnDeleteSetNull
| A constraint that cascades deletes.
const ForeignKeyConstraint | OnDeleteRestrict
| A constraint that restricts deletes.

## Detailed Description

Namespace for the Database Objects (Wt::Dbo).

## Enumeration Type Documentation

## ◆ FieldFlags

enum Wt::Dbo::FieldFlags

Flags.

Enumerator
SurrogateId | Field is a surrogate id.
NaturalId | Field is (part of) a natural id.
Version | Field is an optimistic concurrency version field.
Mutable | Field can be edited.
NeedsQuotes | Field name needs quotes when using in SQL.
ForeignKey | Field is (part of) a foreign key.

## ◆ FlushMode

enum class Wt::Dbo::FlushMode
| strong

Enumeration that indicates the flush mode.

See also
  setFlushMode(), discardUnflushed()

Enumerator
Auto | Dbo decides when to flush changes to a transaction.
Manual | Changes are never automatically flushed.

## ◆ LimitQuery

enum class Wt::Dbo::LimitQuery
| strong

Enum that defines a limit query type.

Oracle is using Rownum, Firebird is using RowsFromTo, and Microsoft SQL Server is using Top instead of limit and offset in SQL

Enumerator
Limit | Use LIMIT and OFFSET.
RowsFromTo | Use ROWS ? TO ? (for Firebird)
Rownum | Use rownum (for Oracle)
OffsetFetch | Use OFFSET (?) ROWS FETCH FIRST (?) ROWS ONLY (adding ORDER BY (SELECT NULL) for SQL Server)

## ◆ SqlDateTimeType

enum class Wt::Dbo::SqlDateTimeType
| strong

Enum that defines a date time type.

Enumerator
Date | Date only.
DateTime | Date and time.
Time | Time duration.

## Function Documentation

## ◆ jsonSerialize() [1/4]

template<typename C >

void Wt::Dbo::jsonSerialize | ( | const C & | c,
|  | std::ostream & | out )

Serialize the given object to the given ostream.

See also
  JsonSerializer::serialize()

## ◆ jsonSerialize() [2/4]

template<typename C >

void Wt::Dbo::jsonSerialize | ( | const collection< C > & | c,
|  | std::ostream & | out )

Serialize a collection of ptrs to the given ostream.

See also
  JsonSerializer::serialize()

## ◆ jsonSerialize() [3/4]

template<typename C >

void Wt::Dbo::jsonSerialize | ( | const ptr< C > & | c,
|  | std::ostream & | out )

Serialize the object pointed to by the given ptr to the given ostream.

See also
  JsonSerializer::serialize()

## ◆ jsonSerialize() [4/4]

template<typename C >

void Wt::Dbo::jsonSerialize | ( | const std::vector< ptr< C > > & | v,
|  | std::ostream & | out )

Serialize a vector of ptrs to the given ostream.

See also
  JsonSerializer::serialize()

## ◆ logToWt()

void Wt::Dbo::logToWt | ( |  | ) |

Redirects all Dbo logging to Wt::log.

Call this once at the start of your program to send all of Wt::Dbo's logging to Wt's logger.

See also
  Wt::Dbo::setCustomLogger()

## ◆ make_ptr()

template<typename T , typename ... Args>

ptr< T > Wt::Dbo::make_ptr | ( | Args &&... | args | ) |

Make a new ptr.

This is a shorthand for

ptr<T>(std::unique_ptr<T>(new T(...)))
Wt::Dbo::ptr
A smart pointer for a database object.
Definition WGlobal.h:283
Wt::Key::T
@ T
'T' key

See also
  Wt::Dbo::Session::addNew()

## ◆ setCustomLogger()

WTDBO_API void Wt::Dbo::setCustomLogger | ( | const WLogSink & | customLogger | ) |
| extern

Sets a custom logger to redirect all logging to.

Instead of using the server's default logger, this will send all logging to some custom WLogSink.

See also
  Wt::Dbo::logToWt()