Using XML - nsc-de/js-database GitHub Wiki

If you want to use xml instead of json, it's quite simple. You just need to replace the json-adapter with a xml-adapter and install the xml-js api

General

Installing xml-js

install xml-js using npm

npm i xml-js

install xml-js using yarn

yarn add xml-js

Async Yaml Adapter

Importing

(You can remove the import of the json adapter and replace it with this one)

Import using Typescript

import { XMLFileAdapter } from 'nscdb/xml_adapter';

Import using Javascript

const { XMLFileAdapter } = require('nscdb/xml_adapter');

Database Creation

When creating a database you have to use the XMLFileAdapter instead of the JsonFileAdapter.

let database = await createDatabase(new XMLFileAdapter ("./database.xml"));

From here it is the same as with the json adapter. The database should act exactly the same.

Sync XML Adapter

Importing

(You can remove the import of the json adapter and replace it with this one)

Import using Typescript

import { SyncXMLFileAdapter } from 'nscdb/xml_adapter';

Import using Javascript

const { SyncXMLFileAdapter } = require('nscdb/xml_adapter');

Database Creation

When creating a database you have to use the SyncXMLFileAdapter instead of the SyncXMLFileAdapter.

let database = createDatabase(new SyncXMLFileAdapter ("./database.xml"));

From here it is the same as with the json adapter. The database should act exactly the same.