CKN Technology Data · Row Utility

CKN Technology Data
Row Class

This page documents the Row class from @ckn-technology/data. A Row wraps a plain JavaScript object and provides standard conversions such as toObject(), toCSV(), and Row.toRow() for consistent row handling across the data layer.

Import

To use the Row class, import it from @ckn-technology/data in your data/model layer.

import { Row } from "@ckn-technology/data";

The Row class is the smallest unit in the tabular model and is typically used together with the Table class.

1. Overview

The Row class represents a single table row. It behaves like a dynamic object where keys and values are assigned directly to the instance and can be accessed using normal property syntax.

  • Wraps a plain JavaScript object into a Row abstraction.
  • Allows direct property access: row.id, row.name, etc.
  • Provides standardized conversions:
    • toObject() → plain object
    • toCSV() → CSV row text
    • Row.toRow(obj) → helper to create a Row
import { Row } from "@ckn-technology/data";

const row = new Row({ id: 1, name: "Alice" });

console.log(row.id);      // 1
console.log(row.name);    // "Alice"
console.log(row.toCSV()); // "1,Alice"

2. Constructor

constructor(obj)

Description
Creates a new Row instance by copying all enumerable keys from the given plain object into the Row instance. Each key/value pair in obj becomes a direct property on the Row.

Signature

constructor(obj: any)

Example

import { Row } from "@ckn-technology/data";

const row = new Row({ id: 1, name: "Alice" });

console.log(row.id);   // 1
console.log(row.name); // "Alice"

3. Instance Methods

3.1 toObject()

Description
Returns a plain JavaScript object containing all properties stored in the Row. This is typically used when exporting, serializing, or transforming table data back into a simple object form.

Signature

toObject(): any

Example

const row = new Row({ id: 1, name: "Alice" });
const obj = row.toObject();

// obj => { id: 1, name: "Alice" }

3.2 toCSV()

Description
Converts the row into a CSV-formatted text line:

  • Property enumeration order is used as the column order.
  • Values are joined by commas (",").
  • No header row is included.
  • No advanced quoting/escaping logic is applied (simple CSV output).

Signature

toCSV(): string

Example

const row = new Row({ id: 1, name: "Alice" });

row.toCSV();
// "1,Alice"

4. Static Methods

4.1 Row.toRow(obj)

Description
Converts a plain object (or any row-like value) into a Row instance by calling the constructor internally. This utility is primarily used to ensure consistent row creation across the library and to make the intent explicit at call sites.

Signature

static toRow(obj: any): Row

Example

const row = Row.toRow({ id: 10, status: "Active" });

console.log(row.id);     // 10
console.log(row.status); // "Active"

5. Summary

The Row class in @ckn-technology/data provides a simple, consistent abstraction for representing a single row of data:

  • Construction – initialize a Row from any plain object using the constructor or Row.toRow().
  • Direct property access – read and write values using normal dot-notation properties.
  • Conversion utilitiestoObject() for plain objects, and toCSV() for simple CSV line output.

Combined with the Table class, the Row abstraction helps standardize how data is stored, transformed, and exported throughout the CKN data stack.