The cross-platform and multi-datasource query module
Want to see support for another data source type? Open an issue so that it can be prioritized and tracked
Future development: continue to add popular database management systems (SQL, NoSQL, whatever...)
I think you should be able to query all mainstream data sources from any machine, and this module is the abstraction for that functionality to be consumed by CLI or GUI tools
$ npm install peacherine
const peacherine = require('peacherine');
const supportedDataSources = peacherine.getDataSourceTypes();
// returns a string array of data source types
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType = 'mssql',
server: '...',
database: '...',
username: '...',
password: '...'
};
const actionOptions = {
query: 'SELECT object_id, name FROM sys.objects'
};
peacherine.run(connectionOptions, actionOptions, (err, results) => {
// handle err and results, if any
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType = 'mssql',
server: '...',
database: '...',
username: '...',
password: '...'
};
peacherine.testConnection(connectionOptions, (err) => {
if (err) {
// failed connection
}
else {
// successful connection
}
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'documentdb',
endpoint: 'https://...documents.azure.com:.../',
key: '...',
database: '...'
};
const actionOptions = {
operation: 'queryCollection',
query: 'SELECT * FROM c',
collection: 'collection-name'
};
peacherine.run(connectionOptions, actionOptions, (err, results) => {
// handle err and results
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'documentdb',
endpoint: 'https://...documents.azure.com:.../',
key: '...',
database: '...'
};
const actionOptions = {
operation: 'createDocument',
collection: 'collection-name',
document: {
id: 'some-id',
message: 'test document creation'
}
};
peacherine.run(connectionOptions, actionOptions, (err, results) => {
// handle err and results
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'documentdb',
endpoint: 'https://...documents.azure.com:.../',
key: '...',
database: '...'
};
peacherine.testConnection(connectionOptions, (err) => {
if (err) {
// failed connection
}
else {
// successful connection
}
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'mongodb',
host: '...',
port: 27017,
database: '...'
};
const actionOptions = {
operation: 'queryCollection',
collection: 'collection-name'
};
peacherine.run(connectionOptions, actionOptions, (err, results) => {
// handle err and results
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'mongodb',
host: '...',
port: 27017,
database: '...'
};
const actionOptions = {
operation: 'queryCollection',
collection: 'collection-name',
filter: {
id: 1
}
};
peacherine.run(connectionOptions, actionOptions, (err, results) => {
// handle err and results
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'mongodb',
host: '...',
port: 27017,
database: '...'
};
const actionOptions = {
operation: 'createDocument',
collection: 'collection-name',
document: {
id: 1,
message: 'test document creation'
}
};
peacherine.run(connectionOptions, actionOptions, (err) => {
// handle err
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'mongodb',
host: '...',
port: 27017,
database: '...'
};
const actionOptions = {
operation: 'updateDocuments',
collection: 'collection-name',
filter: {
id: 1
},
updateOptions: {
$set: {
message: 'my new message'
}
}
};
peacherine.run(connectionOptions, actionOptions, (err, result) => {
// handle err and result
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'mongodb',
host: '...',
port: 27017,
database: '...'
};
actionOptions = {
operation: 'deleteDocuments',
collection: 'collection-name',
filter: {
id: 1
}
};
peacherine.run(connectionOptions, actionOptions, (err, result) => {
// handle err and result
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'mongodb',
host: '...',
port: 27017,
database: '...'
};
peacherine.testConnection(connectionOptions, (err) => {
if (err) {
// failed connection
}
else {
// successful connection
}
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'mysql',
server: '...',
database: '...',
username: '...',
password: '...'
};
const actionOptions = {
query: 'SELECT * FROM information_schema.tables'
};
peacherine.run(connectionOptions, actionOptions, (err, results) => {
// handle err and results, if any
});
const peacherine = require('peacherine');
const connectionOptions = {
dataSourceType: 'mysql',
server: '...',
database: '...',
username: '...',
password: '...'
};
peacherine.testConnection(connectionOptions, (err) => {
if (err) {
// failed connection
}
else {
// successful connection
}
});
Want to contribute? Clone the repo and use npm test
to run unit tests
$ git clone https://github.com/tstringer/peacherine.git
$ cd peacherine
$ npm install
$ npm test