Skip to main content

InventoryItem

Defined in: domain/InventoryItem.ts:20

Represents an inventory item entity. Extends Deletable to support soft deletion.

Remarks

Each inventory item is associated with a wallet and can have a balance, type, and creation date. Use InventoryItem.getTransactions to retrieve the associated transactions for this item.

Example

const item = new InventoryItem(1, 10, "Gold", 2, new Date(), null, 100);
const transactions = await item.getTransactions();
console.log(item.name, item.balance);

Extends

Constructors

Constructor

new InventoryItem(
wallet_id,
id?,
name?,
type_id?,
createdAt?,
deletedAt?,
balance?,
type?): InventoryItem;

Defined in: domain/InventoryItem.ts:51

Creates a new InventoryItem instance.

Parameters

wallet_id

number

The wallet ID associated with this inventory item.

id?

number

The unique identifier for the inventory item.

name?

string

The name of the inventory item.

type_id?

number

The type ID of the inventory item.

createdAt?

Date

The date the inventory item was created.

deletedAt?

The date the inventory item was deleted (if applicable).

null | Date

balance?

number

The balance of the inventory item.

type?

InventoryType

The type of the inventory item.

Returns

InventoryItem

Overrides

Deletable.constructor

Properties

balance?

optional balance: number;

Defined in: domain/InventoryItem.ts:30

The balance of the inventory item.


createdAt?

optional createdAt: Date;

Defined in: domain/InventoryItem.ts:28

The creation date of the inventory item.


deleted

deleted: boolean;

Defined in: types/Deletable.ts:21

Indicates whether the entity is deleted.

Inherited from

Deletable.deleted


deletedAt

deletedAt: null | Date;

Defined in: types/Deletable.ts:23

The date the entity was deleted, or null if not deleted.

Inherited from

Deletable.deletedAt


id?

optional id: number;

Defined in: types/Id.ts:15

The unique identifier for the entity.

Inherited from

Deletable.id


name?

optional name: string;

Defined in: domain/InventoryItem.ts:24

The name of the inventory item.


type?

optional type: InventoryType;

Defined in: domain/InventoryItem.ts:32

The type of inventory as a InventoryType.


type_id?

optional type_id: number;

Defined in: domain/InventoryItem.ts:26

The type ID of the inventory item.


wallet_id

wallet_id: number;

Defined in: domain/InventoryItem.ts:22

The wallet ID associated with this inventory item.

Methods

getTransactions()

getTransactions(): Promise<Transactions>;

Defined in: domain/InventoryItem.ts:74

Retrieves the transactions associated with this inventory item.

Returns

Promise<Transactions>

A promise that resolves to a Transactions instance.