(self: PrimaryKey): stringExtracts the string value from a PrimaryKey.
When to use
Use to read the stable string identifier from a value that implements
PrimaryKey.
Example (Reading primary key values)
import { PrimaryKey } from "effect"
class OrderId implements PrimaryKey.PrimaryKey {
constructor(private timestamp: number, private sequence: number) {}
[PrimaryKey.symbol](): string {
return `order_${this.timestamp}_${this.sequence}`
}
}
const orderId = new OrderId(1640995200000, 1)
console.log(PrimaryKey.value(orderId)) // "order_1640995200000_1"
// Can also be used with simple string-based implementations
const simpleKey = {
[PrimaryKey.symbol]: () => "simple-key-123"
}
console.log(PrimaryKey.value(simpleKey)) // "simple-key-123"accessors
Source effect/PrimaryKey.ts:1231 lines
export const const value: (self: PrimaryKey) => stringExtracts the string value from a PrimaryKey.
When to use
Use to read the stable string identifier from a value that implements
PrimaryKey.
Example (Reading primary key values)
import { PrimaryKey } from "effect"
class OrderId implements PrimaryKey.PrimaryKey {
constructor(private timestamp: number, private sequence: number) {}
[PrimaryKey.symbol](): string {
return `order_${this.timestamp}_${this.sequence}`
}
}
const orderId = new OrderId(1640995200000, 1)
console.log(PrimaryKey.value(orderId)) // "order_1640995200000_1"
// Can also be used with simple string-based implementations
const simpleKey = {
[PrimaryKey.symbol]: () => "simple-key-123"
}
console.log(PrimaryKey.value(simpleKey)) // "simple-key-123"
value = (self: PrimaryKeyself: PrimaryKey): string => self: PrimaryKeyself[const symbol: "~effect/interfaces/PrimaryKey"Defines the unique identifier used to identify objects that implement the PrimaryKey interface.
When to use
Use to implement the PrimaryKey protocol as a computed property key on
classes or object literals that expose a stable string identifier.
symbol]()Referenced by 3 symbols