mdb-reader
Version:
JavaScript library to read data from Access databases
46 lines (45 loc) • 1.77 kB
JavaScript
import { Database } from "../Database.js";
import { ColumnTypes } from "../types.js";
import { readBigInt } from "./bigint.js";
import { readBinary } from "./binary.js";
import { readByte } from "./byte.js";
import { readComplexOrLong } from "./complexOrLong.js";
import { readCurrency } from "./currency.js";
import { readDateTime } from "./datetime.js";
import { readDateTimeExtended } from "./datetimextended.js";
import { readDouble } from "./double.js";
import { readFloat } from "./float.js";
import { readInteger } from "./integer.js";
import { readMemo } from "./memo.js";
import { readNumeric } from "./numeric.js";
import { readOLE } from "./ole.js";
import { readRepID } from "./repid.js";
import { readText } from "./text.js";
const readFnByColType = {
[]: readBigInt,
[]: readBinary,
[]: readByte,
[]: readComplexOrLong,
[]: readCurrency,
[]: readDateTime,
[]: readDateTimeExtended,
[]: readDouble,
[]: readFloat,
[]: readInteger,
[]: readComplexOrLong,
[]: readText,
[]: readMemo,
[]: readNumeric,
[]: readOLE,
[]: readRepID,
};
export function readFieldValue(buffer, column, database) {
if (column.type === ColumnTypes.Boolean) {
throw new Error("readFieldValue does not handle type boolean");
}
const read = readFnByColType[column.type];
if (!read) {
return `Column type ${column.type} is currently not supported`;
}
return read(buffer, column, database);
}