dpq.attributes

Members

Enums

IgnoreAttribute
enum IgnoreAttribute

Specifies that the member should be completely ignored as far as the DB is concerned.

PrimaryKeyAttribute
enum PrimaryKeyAttribute

@PK / @Pkey / @PrimaryKey attribute -- specifies that the member should be a PK. Coumpound PKs are not supported.

Functions

attribute
AttributeAttribute attribute(string name)

@attribute / @attr -- specifies the name of the attribute to be used.

relation
RelationAttribute relation(string name)

@relation attribute -- specifies the relation/type name to be used for Connection's ORM functions. If none is set, dpq will default to the structure's name in lower_snake_case.

suffix
ColumnSuffixAttribute suffix(string suffix)

Allows placing any text after the column definition when ensureSchema is ran.

type
PGTypeAttribute type(string type)

Specifies the type for the member, overrides any serialiser-provided type

Manifest constants

notNull
enum notNull;

A shortcut to @suffix("NOT NULL")

Properties

index
IndexAttribute index [@property getter]

@index

serial
PGTypeAttribute serial [@property getter]

Shortcut for @type("SERIAL")

serial4
PGTypeAttribute serial4 [@property getter]

SHORTCUT for @type("SERIAL4")

serial8
PGTypeAttribute serial8 [@property getter]

SHORTCUT for @type("SERIAL8")

uniqueIndex
IndexAttribute uniqueIndex [@property getter]

@uniqueIndex

Structs

ForeignKeyAttribute
struct ForeignKeyAttribute

Specifies that the member is a foriegn key, ensureSchema will create a FK constraint as well as an index for it. Finds the referenced table's PK by itself.

IndexAttribute
struct IndexAttribute

Specifies that the member/column should have an index created on it. If unique is set, it well be a unique index.

Templates

AttributeList2
template AttributeList2(T, string prefix = "", string asPrefix = "", bool ignorePK = false, fields...)

Returns a list of Columns for all the given type's serialisable members, with their actual names as they're used in SQL.

SnakeCase
template SnakeCase(string str)

Transforms the given string into lower_snake_case at compile-time. Used for attribute and relation names and probably not very useful outside the library itself.

attributeName
template attributeName(alias R)

Attribute name for the given type, can be specified with @attribute. If @attribute is not specified, the member's name will just be lower_snake_cased and returned.

filterSerialisableMembers
template filterSerialisableMembers(T, fields...)

A filter implementation for serialisableMembers

getMembersByUDA
template getMembersByUDA(T, alias attribute)

Workaround for getSymbolsByUDA not working on structs/classes with private members. Returns all the structure's members that have the given UDA.

isPK
template isPK(alias T, string m)

Returns true if the member m is a PK on T.

isRWField
template isRWField(T, string M)

Determines if a member is a public, non-static, de-facto data field. In addition to plain data fields, R/W properties are also accepted.

isRWPlainField
template isRWPlainField(T, string M)

Determins if a member is a public, non-static data field.

primaryKeyAttributeName
template primaryKeyAttributeName(T)

Returns the name of the PK attribute (SQL name)

primaryKeyName
template primaryKeyName(T)

Returns a string containing the name of the type member that is marked with @PK

relationName
template relationName(alias R)

Relation/type name for the given type, can be set with @relation attribute. If @relation is not set, type's name will be lower_snake_cased.

serialisableMembers
template serialisableMembers(T)

Gives a list of all the structure's members that will be used in the DB. Ignores @ignore members, non-RW and non-public members.

Meta