A Node.js SDK for interacting with ApertureDB, providing a simple and intuitive interface for database operations.
To install directly from GitHub, add the following to your package.json dependencies:
{
"dependencies": {
"@coffeeblackai/aperturedb-node": "coffeeblackai/aperturedb-node"
}
}Or install using npm:
npm install github:coffeeblackai/aperturedb-nodeOr using yarn:
yarn add github:coffeeblackai/aperturedb-nodeEnsure you have a .env file in the root of your project with the following variables:
APERTURE_HOST=<your-aperture-host>
APERTURE_USER=<your-aperture-username>
APERTURE_PASSWORD=<your-aperture-password>
To execute a raw query, you can use the rawQuery method of the ApertureClient. Here is an example:
const query = [{
"FindEntity": {
"with_class": "test",
"results": {
"all_properties": true
}
}
}];
const [response, blobs] = await client.rawQuery(query);
console.log(response);You can perform various entity operations such as finding entities with specific constraints:
const query = [{
"FindEntity": {
"with_class": "test",
"constraints": {
"name": ["==", "test_entity"]
},
"results": {
"all_properties": true
}
}
}];
const [response, blobs] = await client.rawQuery(query);
console.log(response);To create a new entity, use the addEntity method:
const entity = await client.entities.addEntity('dataset', {
name: 'test-dataset',
description: 'A test dataset'
});To find an entity by name, use the findEntities method:
const entities = await client.entities.findEntities({
with_class: 'dataset',
constraints: { name: ['==', 'test-dataset'] }
});
console.log(entities);To update an entity's properties, use the updateEntity method:
await client.entities.updateEntity({
with_class: 'dataset',
properties: { description: 'An updated test dataset' },
constraints: { _uniqueid: ['==', testEntityId] }
});To delete an entity, use the deleteEntity method:
await client.entities.deleteEntity({
class: 'dataset',
constraints: { _uniqueid: ['==', testEntityId] }
});