# actordb

> ActorDB Connector for node.js

Latest version **0.10.1** (published 2015-11-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install actordb
pnpm add actordb
yarn add actordb
bun add actordb
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.10.1 |
| Published | 2015-11-25 |
| First published | 2015-11-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Biokoda |
| Maintainers | djustinek |
| Keywords | actordb, node, thrift, client |

## Links

- npm: https://www.npmjs.com/package/actordb
- Repository: https://github.com/biokoda/actordb_nodejs
- Issues: https://github.com/biokoda/actordb_nodejs/issues
- npm.io page: https://npm.io/package/actordb

## Dependencies (2)

- [thrift](https://npm.io/package/thrift.md) 0.9.3
- [es6-promise](https://npm.io/package/es6-promise.md) 3.0.2

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.10.1 (latest) — 2015-11-25
- 0.10.0 — 2015-11-25

## README

# ActorDB connector for Node.js


# Installation

The recommended way to get started using the ActorDB connector for Node.js is by using the `npm` (Node Package Manager) to install the dependency.

`npm install actordb`

## ActorDBClient Interface

### Create a single connection to database

```
var ActorDB = require('actordb');
var adbc = ActorDB.connectSingle({ host:'localhost', port:33306, username:"<username>", password:"<password>" });
adbc.connect().then(function(db){
    // connected code ...
  });
```

### Close a single connection

```
adbc.close();
```

### Create a pool of connections to database

```
var ActorDB = require('actordb');
var adbc_pool = ActorDB.connectionPool({ host:'localhost', port:33306, username:"<username>", password:"<username>" }, { pool_size : 5 });
adbc_pool.connect().then(function(){
  // fetch a ActorDBClient instance
  adbc = adbc_pool.db();
  // execute actions like on a single connection
  adbc.exec_sql(...)
});  
```

### Close a pool of connections

```
adbc_pool.close();
```

### Executing SQL statement

```
adbc.exec_sql("ACTOR user(myid1); SELECT * FROM contact;").then(function(result){
  // work with the result set
  console.log(result);
});
```

### Executing a single SQL statement with parameters

```
client1.exec_single_param("myuserid", "user", "INSERT INTO contact (contact_id, contact_name) VALUES (?1,?2);", [ 'CREATE' ], [ ["contact_id", "contact_name"] ] ).then(function(result) {
  // work with the result set
  console.log(result);
}).catch(function(err){
  // handle error
  console.log(err);
});

```

### Fetching Unique ID

```
client1.uniqid().then(function(uniqid){
  console.log("uniqid:");
  console.log(uniqid);
});
```
### Fetching DB generated salt

```
client1.salt().then(function(salt){
  console.log("salt:");
  console.log(salt);
});
```

### Executing a single SQL statement

```
client1.exec_single("myuserid123", "user","INSERT INTO contact (contact_id, contact_name) VALUES ('2131244','scott');",[ 'CREATE' ]).then(function(result){
  console.log("insert2 query result:");
  console.log(result);
}).catch(function(err){
  console.log("insert2 query error:");
  console.log(err);
});
```

### Fetching all Actor types

```
adbc.actor_types().then(function(types){
  // work with actor types
  console.log(types);
});
```

### Fetching all Tables for an Actor Type

```
adbc.actor_tables("actor_type").then(function(actor_tables){
  // work with table list
  console.log(actor_tables);
});
```

### Fetching all columns for a Table within an Actor Type

```
client1.actor_columns("user", "contact").then(function(column_list){
  // work with column list
  console.log(column_list);
});
```

## Example usage

### Connecting through a single connection and performing a query

```
var ActorDB = require('actordb');
var client = ActorDB.connectSingle({ host:'localhost', port:33306, username:"actordb_username", password:"actordb_password" });

client.connect(function(err, db) {
    client.exec_sql("ACTOR user(userid1); SELECT * FROM data;", function(err,data){
    client.close();
    console.log(data);
    });  
});
```

### Setting up a pool of connections and performing a query

```
var ActorDB = require('actordb');
var pool = ActorDB.connectionPool({ host:'localhost', port:33306, username:"actordb_username", password:"actordb_password" }, { pool_size : 3 });

pool.connect().then(function(){
  pool.db().exec_sql("ACTOR user(userid1); SELET * FROM data;").then(function(r){
    console.log(r);
    pool.close();
  });
});
```

## Questions / Feature Requests / BUgs

Are you missing something out? Have you found a bug? Want to discuss something or help with the project?

Please open an issue or pull request on GitHub:

- [ActorDB node.js connector issues](https://github.com/biokoda/actordb_nodejs/issues)
- [ActorDB nodejs pull requests](https://github.com/biokoda/actordb_nodejs/pulls)

## Next Steps

 * [ActorDB Documentation](http://www.actordb.com/)
 * [Star us on GitHub](https://github.com/biokoda/actordb_nodejs)

---
_Source: https://npm.io/package/actordb · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
