Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/pg_mem/datatypes/datatype-base.ts>TypeBase

An in memory postgres DB instance for your unit tests
Latest
class TypeBase
implements _IType<TRaw>, _RelationBase
Abstract
import { TypeBase } from "https://deno.land/x/pg_mem@3.0.3/datatypes/datatype-base.ts";

Constructors

new
TypeBase(typeId: number | null)

select a.oid, a.typname, b.typcategory from pg_catalog.pg_type a left join pg_catalog.pg_type b on b.oid = a.typelem

Type Parameters

optional
TRaw = any

Properties

private
optional
_asArray: _IType<TRaw[]>
private
optional
_asList: _IType<TRaw[]>
readonly
name: string
abstract
primary: DataType
readonly
primaryName: string
readonly
reg: Reg
readonly
type: "type"
readonly
[isType.TAG]

Methods

private
_convert(
_to: _IType<any>,
perform: (a: Evaluator, to: _IType) => Evaluator<any> | nil,
): IValue
canCast(to: _IType<TRaw>): boolean | nil

Can be explicitely casted to

Can constant literals be converted implicitely (without a cast... i.e. you can use both values as different values of a case expression, for instance)

cast(_a: IValue<TRaw>, _to: _IType<any>): IValue

Perform cast

Perform implicit conversion

optional
doBuildFrom(value: Evaluator, from: _IType): Evaluator<TRaw> | nil

Perform conversion given type to this type (inverse of doCast())

optional
doCanBuildFrom(from: _IType): boolean | nil

Can be built to from (inverse of doCanCast())

optional
doCanCast(to: _IType<TRaw>): boolean | nil

Can be casted to

optional
doCanConvertImplicit(to: _IType<TRaw>): boolean
optional
doCast(value: Evaluator<TRaw>, to: _IType<TRaw>): Evaluator<any> | nil

Perform conversion from this type to given type

doEquals(a: TRaw, b: TRaw): boolean
optional
doGetHash(value: TRaw): string | number

Compute a custom unicty hash for a non null value

doGt(a: TRaw, b: TRaw): boolean
doLt(a: TRaw, b: TRaw): boolean
optional
doPrefer(type: _IType<TRaw>): _IType | null
drop(t: _Transaction): void
equals(a: TRaw, b: TRaw): boolean | null
ge(a: TRaw, b: TRaw): boolean | null
gt(a: TRaw, b: TRaw): boolean | null
hash(value: any): string | number | null
le(a: TRaw, b: TRaw): boolean | null
lt(a: TRaw, b: TRaw): boolean | null

When performing 'a+b', will be given 'b' type, this returns the prefered resulting type, or null if they are not compatible

toString(): string