use-postgres 0.1.0

Feature-gated facade crate for RustUse PostgreSQL primitives
Documentation

use-postgres

Feature-gated facade crate for RustUse PostgreSQL primitives.

use-postgres re-exports focused primitive crates for PostgreSQL identifiers, type labels, schemas, tables, columns, constraints, indexes, sequences, enum types, and extensions. It does not connect to PostgreSQL, execute SQL, parse SQL, introspect live databases, run migrations, or model an ORM.

Install

[dependencies]
use-postgres = "0.1.0"

Example

# #[cfg(feature = "full")]
# {
use use_postgres::{column, constraint, index, schema, table, ty};

let users = table::PgTableRef::qualified(
    schema::PgSchemaName::public(),
    table::PgTableName::new("users")?,
);
let id = column::PgColumn::with_built_in_type(
    column::PgColumnName::new("id")?,
    ty::PgBuiltInType::BigInt,
)
.with_nullability(column::PgNullability::NotNull);
let primary_key = constraint::PgConstraint::new(constraint::PgConstraintKind::PrimaryKey)
    .with_columns(vec![column::PgColumnName::new("id")?]);
let index = index::PgIndex::new(index::PgIndexName::new("users_id_idx")?)
    .with_table(users.clone())
    .with_method(index::PgIndexMethod::Btree);

assert_eq!(users.to_string(), "public.users");
assert_eq!(id.type_name().as_str(), "bigint");
assert_eq!(primary_key.kind(), constraint::PgConstraintKind::PrimaryKey);
assert_eq!(index.method(), index::PgIndexMethod::Btree);
# }
# Ok::<(), Box<dyn std::error::Error>>(())

Features

The default full feature enables all focused crates. Disable default features and enable only the modules you need for a narrow facade surface.