{"id":13691979,"url":"https://github.com/SoftwareAG/adabas-tcp","last_synced_at":"2025-05-02T16:31:07.878Z","repository":{"id":41853746,"uuid":"235119536","full_name":"SoftwareAG/adabas-tcp","owner":"SoftwareAG","description":"Access to an Adabas Database from Node.js using the Adabas TCP connection","archived":false,"fork":false,"pushed_at":"2024-06-17T08:54:36.000Z","size":1020,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-09-21T13:20:17.003Z","etag":null,"topics":["adabas","javascript","nodejs","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/SoftwareAG.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,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2020-01-20T14:24:30.000Z","updated_at":"2024-06-17T08:53:40.000Z","dependencies_parsed_at":"2023-12-05T12:50:57.726Z","dependency_job_id":null,"html_url":"https://github.com/SoftwareAG/adabas-tcp","commit_stats":{"total_commits":46,"total_committers":5,"mean_commits":9.2,"dds":0.4565217391304348,"last_synced_commit":"3641e76250d22a8adea1a770c6ed8484c74c104a"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftwareAG%2Fadabas-tcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftwareAG%2Fadabas-tcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftwareAG%2Fadabas-tcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoftwareAG%2Fadabas-tcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SoftwareAG","download_url":"https://codeload.github.com/SoftwareAG/adabas-tcp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224034250,"owners_count":17244757,"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":["adabas","javascript","nodejs","typescript"],"created_at":"2024-08-02T17:00:52.229Z","updated_at":"2024-11-12T17:32:35.017Z","avatar_url":"https://github.com/SoftwareAG.png","language":"TypeScript","funding_links":[],"categories":["Adabas and Natural"],"sub_categories":["![icon-Adabas-64x64](https://user-images.githubusercontent.com/23717841/230384852-da5ff0f6-5283-447d-9072-43b2c740d535.png) Adabas"],"readme":"# Adabas TCP\n\nAccess to an Adabas Database from Node.js using the Adabas TCP connection.\n\nIt offers the classical *CRUD* access methods for Adabas:\n\n* _C_ reate - inserts an new Adabas record\n* _R_ ead - read Adabas records\n* _U_ pdate - update an Adabas record\n* _D_ elete - delete an Adabas record\n\n## Installation\n\n```shell\nnpm install adabas-tcp\n```\n\n## Introduction\n\nThis simple example shows how to read all records of file 11 and writes the result to the console:\n\n```typescript\nconst Adabas = require('adabas-tcp').Adabas;\n\nconst adabas = new Adabas('localhost', 60001);\nadabas.read({ fnr: 11 }).then( result =\u003e {\n    console.log(result);\n    adabas.close().then(  () =\u003e adabas.disconnect() );\n});\n```\n\nWhat it does is to read the File Description Table of the file and add all available fields to the format buffer. The result is an array of Javascript objects:\n\n```\n[\n  { ISN: 1,\n    AA: '50005800',\n    AB: { AC: 'SIMONE', AE: 'ADAM', AD: '' },\n    AF: 'M',\n    AG: 'F',\n    AH: 712981,\n    A1: { AI: [ '26 AVENUE RHIN ET DA' ], AJ: 'JOIGNY', AK: '89300', AL: 'F' },\n    A2: { AN: '1033', AM: '44864858' },\n    AO: 'VENT59',\n    AP: 'CHEF DE SERVICE',\n    AQ: [ { AR: 'EUR', AS: 963, AT: [ 138] } ],\n    A3: { AU: 19, AV: 5 },\n    AW: [ { AX: 19990801, AY: 19990831 } ],\n    AZ: [ 'FRE', 'ENG' ]\n  },\n  { ISN: 2,\n...\n```\n\n## General\n\nTo hide the complexity of an Adabas call with all the buffers, short names and options from the user, this implementation offers a high level API which generates all buffers from the provided metadata.\n\n### Data Representation\n\nThe Adabas data is represented as a Javascript object. This means the read method returns a Javascript object and the insert and update methods access a Javascript object as input. Here is an example for the Javascript object for an Employees record:\n\n```javascript\nconst record = {\n    'Personnel Id': '50001234',\n    'First Name'  : 'John',\n    'Name'        : 'Doe',\n    'Middle Name' : 'M.',\n    'City'        : 'Seattle',\n    'Country'     : 'USA'\n};\n```\n\nThe type of object attributes must match the Adabas types. This means a numeric type in Adabas must be a Javascript type of number. These types are validated during the processing and an error is thrown if there are incompatibilites.\n\n#### Multiple Fields\n\nMultiple fields are represented as arrays.\n\n#### Groups\n\nA group is a Javascript object.\n\n#### Periodic Groups\n\nA periodic group is an array of Javascript objects.\n\n#### Data Representation Example\n\nBelow is an example of an object:\n\n```javascript\n{\n    ISN: 207,\n    'Personnel Id': '11100107',\n    'Full Name': { 'First Name': 'HELGA', Name: 'SCHMIDT' },\n    Name: 'SCHMIDT',\n    Language: [ 'GER', 'FRE' ],\n    Income:\n        [\n            { 'Currency Code': 'EUR', Salary: 18461, Bonus: [ 1025, 75] },\n            { 'Currency Code': 'EUR', Salary: 16410, Bonus: [] }\n        ]\n}\n```\n\n## Classes\n\n### AdabasMap\n\nThe AdabasMap class contains the metadata for the Adabas call.\n\n#### AdabasMap Constructor\n\nThe constructor has the file number as parameter.\n\n#### Fields\n\nFor each field that is accessed the following information must be provided:\n\n* type (regular field, multiple field, periodic group)\n* format\n* length\n* short name\n* options\n\nWith the options, the long name, precision, max occurrence, etc. can be provided.\n\nEach Adabas field is defined like this:\n\n```javascript\nalpha(8, 'AA', { name: 'Personnel Id' })\n```\n\nMeaning that the Adabas field is of type 'alpha', has a length of 8 and the short name is 'AA'. In the returned object the attribute is named 'Personnel Id'.\n\nTo add the fields to the map a function must be used. The following functions are implemented:\n\n* alpha (A)\n* binary (B)\n* fixed (F)\n* float (G)\n* packed (P)\n* unpacked (U)\n* wide (W)\n\nMultiple fields must set the 'occ' attribute in the options:\n\n```javascript\nalpha(3, 'AZ', { name: 'Language', occ: 5 }) // multiple field\n```\n\nFor groups another function must be used where instead of the length a map for the group is provided:\n\n```javascript\ngroup(FullName, 'AB', { name: 'FullName' }) // group\n```\n\nPeriodic groups are similar to groups. The difference is that the 'occ' attribute is set in the options:\n\n```javascript\ngroup(Income, 'AQ', { name: 'Income', occ: 6 }) // periodic group\n```\n\n#### Import\n\n##### Typescript\n\n``` javascript\nimport { Adabas, AdabasMap } from 'adabas-tcp';\n```\n\n##### Javascript\n\n``` javascript\nconst Adabas = require('adabas-tcp').Adabas;\nconst AdabasMap = require('adabas-tcp').AdabasMap;\n```\n\n#### Fields Example\n\nHere is an example for an Employees file (file number 11):\n\n```javascript\n// define elements of the periodic group\nconst Income = new AdabasMap()\n    .alpha(3, 'AR', { name: 'Currency Code' })\n    .packed(5, 'AS', { name: 'Salary' })\n    .packed(5, 'AT', { name: 'Bonus', occ: 5 }) // multiple field within periodic group\n    ;\n\n// define a group\nconst FullName = new AdabasMap()\n    .alpha(20, 'AC', { name: 'First Name' })\n    .alpha(20, 'AE', { name: 'Name' })\n    ;\n\n// define the adabas record\nconst Map = new AdabasMap(11)\n    .alpha(8, 'AA', { name: 'Personnel Id' })\n    .group(FullName, 'AB', { name: 'FullName' }) // group\n    .alpha(20, 'AE', { name: 'Name' })\n    .alpha(3, 'AZ', { name: 'Language', occ: 5 }) // multiple field\n    .group(Income, 'AQ', { name: 'Income', occ: 6 }) // periodic group\n    ;\n```\n\n### Adabas\n\nThe *Adabas* class does the Adabas calls.\n\n#### Adabas Constructor\n\nThe Adabas class has the database number as a required parameter. Options for multifetch or logging can be added:\n\n```javascript\nconst adabas = new Adabas('localhost', 49152, { multifetch: 20 } );\n```\n\n#### Methods\n\nThe *create*, *read*, *update* and *delete* methods need the map or a file number as parameter. If the file number is provided the File Description Table of the file is read and a map containing all fields is created from these definitions.\n\nEach command has some parameters provided as an object to control the command. At least a map or file number must be provided. See examples below.\n\nThe following parameters are supported:\n\n```javascript\nexport interface CallData {\n    map?: AdabasMap,\n    fnr?: number,\n    isn?: number,\n    object?: any,\n    criteria?: string,\n    fields?: string[]\n}\n```\n\nHere are examples for these methods.\n\n##### create(CallData)\n\nParameter:\n\n* map/fnr: map or file number\n* object: that is stored\n\nStore object 'create' using the map 'empl':\n\n```javascript\nadabas.create( { map: empl, object: create } );\n```\n\n##### read(CallData)\n\nParameter:\n\n* map/fnr: map or file number\n* criteria: return only objects that meet the criteria\n* isn: read a single ISN\n* fields[]: limit the returned fields\n\nRead all data from file 11:\n\n```javascript\nadabas.read( { fnr: 11 } );\n```\n\nRead ISN 207 using the map 'empl':\n\n```javascript\nadabas.read( { map: empl, isn: 207 } );\n```\n\n##### update(CallData)\n\nParameter:\n\n* map/fnr: map or file number\n* criteria: return only objects that meet the criteria\n* object: that is stored\n\nUpdate the corresponding record where 'Personnel Id' equals 'Test1234' with object 'update':\n\n```javascript\nadabas.update( { map: empl, criteria: 'Personnel Id=Test1234', object: update } );\n```\n\n##### delete(CallData)\n\nParameter:\n\n* map/fnr: map or file number\n* criteria: return only objects that meet the criteria\n\nDelete record where 'Personnel Id' equals 'Test1234':\n\n```javascript\nadabas.delete( {map: empl, criteria: 'Personnel Id=Test1234' } );\n```\n\n##### endTransaction()\n\nPerforms an end of transaction. The data is committed to the database.\n\n##### backoutTransaction()\n\nPerforms a backout of this transaction.\n\n##### close()\n\nPerforms a close of the database.\n\n## Known Problems\n\n* Alpha fields with length 0 and LOB fields are currently not supported.\n\n## Dislaimer\n\nUtilities and samples shown here are not official parts of the Software AG products. These utilities and samples are not eligible for technical assistance through Software AG Global Support. Software AG makes no guarantees pertaining to the functionality, scalability , robustness, or degree of testing of these utilities and samples. Customers are strongly advised to consider these utilities and samples as \"working examples\" from which they should build and test their own solutions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSoftwareAG%2Fadabas-tcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSoftwareAG%2Fadabas-tcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSoftwareAG%2Fadabas-tcp/lists"}