Official Node.js Client for AgredaDB - The Limitless Database for AI
npm install agredadbOfficial Node.js client for AgredaDB v2.0 - The Limitless Database.
``bash`
npm install agredadb
Or install from source:
`bash`
cd sdk/nodejs
npm install
`javascript
const { AgredaDBClient } = require('agredadb');
// Connect to AgredaDB
const client = new AgredaDBClient('localhost:19999');
// Insert data
await client.insert('users', {
id: 1,
name: 'John Doe',
email: 'john@example.com',
vector: [0.1, 0.2, 0.3, 0.4],
metadata: { type: 'user' }
});
// Get data
const user = await client.get('users', 'id', 1);
console.log(user);
// Vector search
const results = await client.search('users', [0.1, 0.2, 0.3, 0.4], 10);
// Close connection
client.close();
`
- ✅ Simple and intuitive API
- ✅ Promise-based (async/await)
- ✅ Vector similarity search
- ✅ Batch operations
- ✅ TypeScript support
- ✅ Full error handling
#### constructor(host, useHttps)
Create a new client instance.
- host (string): Server address (default: 'localhost:19999')useHttps
- (boolean): Use HTTPS instead of HTTP (default: false)
#### insert(table, data)
Insert a single record.
- table (string): Table namedata
- (object): Record data
- Returns: Promise
#### insertBatch(table, dataList)
Insert multiple records.
- table (string): Table namedataList
- (Array
#### get(table, key, value)
Get a record by key.
- table (string): Table namekey
- (string): Key field namevalue
- (any): Key value
- Returns: Promise
#### search(table, vector, limit)
Vector similarity search.
- table (string): Table namevector
- (Arraylimit
- (number): Maximum number of results (default: 10)
- Returns: Promise
#### delete(table, key, value)
Delete a record.
- table (string): Table namekey
- (string): Key field namevalue
- (any): Key value
- Returns: Promise
#### query(table, filter)
Query records with filters.
- table (string): Table namefilter
- (object): Filter conditions
- Returns: Promise
#### close()
Close the client connection.
`javascript`
const users = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Charlie' }
];
await client.insertBatch('users', users);
`javascript
const queryVector = [0.1, 0.2, 0.3, 0.4];
const results = await client.search('embeddings', queryVector, 5);
for (const result of results) {
console.log(ID: ${result.id}, Score: ${result.score});`
}
`javascript`
try {
await client.insert('users', { id: 1, name: 'John' });
} catch (error) {
console.error('Insert failed:', error.message);
}
`typescript
import { AgredaDBClient, SearchResult } from 'agredadb';
const client = new AgredaDBClient('localhost:19999');
const results: SearchResult[] = await client.search(
'embeddings',
[0.1, 0.2, 0.3, 0.4],
10
);
``
- Node.js >= 14.0.0
- axios >= 1.6.0
GNU Affero General Public License v3 (AGPLv3)
Luis Eduardo Agreda Gonzalez
- Email: luisagreda.ai@gmail.com
- LinkedIn: luis-agreda-artificial-intelligence-engineer