{"id":24973387,"url":"https://github.com/jshinonome/jkdb","last_synced_at":"2025-04-11T08:44:08.195Z","repository":{"id":61012171,"uuid":"514891355","full_name":"jshinonome/jkdb","owner":"jshinonome","description":"javascript interface for kdb+/q","archived":false,"fork":false,"pushed_at":"2023-10-09T16:18:56.000Z","size":77,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T06:13:27.473Z","etag":null,"topics":["javascript","kdb","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jshinonome.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-17T16:07:19.000Z","updated_at":"2024-09-27T06:45:21.000Z","dependencies_parsed_at":"2023-01-30T12:45:52.209Z","dependency_job_id":null,"html_url":"https://github.com/jshinonome/jkdb","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshinonome%2Fjkdb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshinonome%2Fjkdb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshinonome%2Fjkdb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jshinonome%2Fjkdb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jshinonome","download_url":"https://codeload.github.com/jshinonome/jkdb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247698419,"owners_count":20981346,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","kdb","nodejs"],"created_at":"2025-02-03T18:59:06.827Z","updated_at":"2025-04-11T08:44:08.173Z","avatar_url":"https://github.com/jshinonome.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jkdb\n\n[![](https://img.shields.io/npm/dm/jkdb?labelColor=4a148c\u0026color=9c27b0\u0026style=flat)](https://www.npmjs.com/package/jkdb)\n\nA zero dependency javascript Node.js package to interface with kdb+/q (v2.6+).\n\n## Installation\n\n```\nnpm install --save-dev jkdb\n```\n\n## Quick Start\n\n### Connect to a q Process\n\n```javascript\nconst { QConnection } = require(\"jkdb\");\nconst q = new QConnection({ port: 1800 });\nq.connect((err) =\u003e {\n  if (err) throw err;\n  console.log(\"connected\");\n  // send query from here\n});\n```\n\n### Connect to a TLS-protected q Process\n\n```javascript\nconst { QConnection } = require(\"jkdb\");\nconst q = new QConnection({ port: 1800, useTLS: true });\nq.connect((err) =\u003e {\n  if (err) throw err;\n  console.log(\"connected\");\n  // send query from here\n});\n```\n\n### Connect to a q Process with Credentials\n\n```javascript\nconst { QConnection } = require(\"jkdb\");\nconst q = new QConnection({ port: 1800, user: \"user\", password: \"password\" });\nq.connect((err) =\u003e {\n  if (err) throw err;\n  console.log(\"connected\");\n  // send query from here\n});\n```\n\n### Send a Sync Query\n\n```javascript\nq.sync(\"(+/) til 10\", (err, res) =\u003e {\n  if (err) throw err;\n  console.log(\"result: \", res);\n  // result: 45\n});\n```\n\n### Send a Sync Function Call\n\n```javascript\nq.sync([\"(*/)\", [22, 27, 45]], (err, res) =\u003e {\n  if (err) throw err;\n  console.log(\"result: \", res);\n  // result: 26730\n});\n```\n\n### Send a Sync Function Call with Multiple Parameters\n\n```javascript\nq.sync(\n  [\n    \"mmu\",\n    [1, 2, 3],\n    [\n      [1, 2, 3],\n      [4, 5, 6],\n      [7, 8, 9],\n    ],\n  ],\n  (err, res) =\u003e {\n    if (err) throw err;\n    console.log(\"result: \", res);\n    // result: 30,36,42\n  }\n);\n```\n\n### Send an Async Query\n\n```javascript\nq.asyn(\"show 99\", (err) =\u003e {\n  if (err) throw err;\n});\n```\n\n### Send an Async Function Call\n\n```javascript\nq.asyn([\"show\", 99], (err) =\u003e {\n  if (err) throw err;\n});\n```\n\n### Subscribe\n\n```javascript\nq.on(\"upd\", (table, data) =\u003e {\n  console.log(table, data);\n});\n\nq.sync(\".u.sub[`trade;`7203.T]\", (err, _res) =\u003e {\n  if (err) throw err;\n});\n```\n\n### Close q Connection\n\n```javascript\nq.close(() =\u003e {\n  console.log(\"closed\");\n});\n```\n\n## Date Types\n\n### Deserialization\n\nDeserialization of long and timestamp can be controlled by QConnection arguments `useBigInt` and `includeNanosecond`.\n\n| k type     | argument          | javascript type | k null                           | infinity | -infinity |\n| ---------- | ----------------- | --------------- | -------------------------------- | -------- | --------- |\n| boolean    |                   | Boolean         |                                  |          |           |\n| guid       |                   | String          | 00000000000000000000000000000000 |          |           |\n| byte       |                   | Number          |                                  |          |           |\n| short      |                   | Number          | NaN                              | Infinity | -Infinity |\n| int        |                   | Number          | NaN                              | Infinity | -Infinity |\n| long       |                   | Number          | NaN                              | Infinity | -Infinity |\n| long       | useBigInt         | BigInt          | NaN                              | Infinity | -Infinity |\n| real       |                   | Number          | NaN                              | Infinity | -Infinity |\n| float      |                   | Number          | NaN                              | Infinity | -Infinity |\n| char       |                   | String          | ' '                              |          |           |\n| symbol     |                   | String          | ''                               |          |           |\n| timestamp  |                   | Date            | null                             | null     | null      |\n| timestamp  | includeNanosecond | String          | ''                               | ''       | ''        |\n| month      |                   | String          | null                             | null     | null      |\n| date       |                   | Date            | null                             | null     | null      |\n| date       | dateToMillisecond | Number          | NaN                              | Infinity | -Infinity |\n| datetime   |                   | Date            | null                             | null     | null      |\n| datetime   | dateToMillisecond | Number          | NaN                              | Infinity | -Infinity |\n| timespan   |                   | String          | null                             | null     | null      |\n| minute     |                   | String          | null                             | null     | null      |\n| second     |                   | String          | null                             | null     | null      |\n| time       |                   | String          | null                             | null     | null      |\n| dict       |                   | Object          |                                  |          |           |\n| list       |                   | Array           |                                  |          |           |\n| table      |                   | Object          |                                  |          |           |\n| lambda     |                   | String          |                                  |          |           |\n| projection |                   | Array           |                                  |          |           |\n\n### Serialization\n\n#### Atom\n\n| javascript type | k type    |\n| --------------- | --------- |\n| Boolean         | boolean   |\n| Number          | float     |\n| String          | chars     |\n| Date            | timestamp |\n\n#### Array\n\n| javascript type | Symbol.for('kType') | k type    |\n| --------------- | ------------------- | --------- |\n| Boolean Array   | b                   | boolean   |\n| String Array    | g                   | guid      |\n| Number Array    | i                   | int       |\n| Number Array    | j                   | long      |\n| Number Array    | f                   | float     |\n| String Array    | c                   | char      |\n| String Array    | s                   | symbol    |\n| Date Array      | p                   | timestamp |\n| Date Array      | d                   | date      |\n| Date Array      | z                   | datetime  |\n\nUse `Symbol.for('kType')` to specify k type for the array, e.g.\n\n```javascript\nconst ints = [99, 11, 3, 3];\nints[Symbol.for(\"kType\")] = \"j\";\n```\n\n#### Object without meta\n\nConvert to a dictionary, keys are symbols, e.g.\n\n```javascript\nconst dict = { sym: \"8306.T\", price: 668.2 };\n```\n\n#### Object with meta\n\nConvert to a table, e.g.\n\n```javascript\nconst table = {\n  sym: [\"AXJO\", \"AXJO\"],\n  date: [new Date(\"2021-05-13\"), new Date(\"2021-05-14\")],\n  open: [7000, 6000],\n};\ntable[Symbol.for(\"meta\")] = {\n  c: [\"sym\", \"date\", \"open\"],\n  t: [\"s\", \"d\", \"f\"],\n};\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshinonome%2Fjkdb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjshinonome%2Fjkdb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjshinonome%2Fjkdb/lists"}