{"id":15771779,"url":"https://github.com/trstringer/peacherine","last_synced_at":"2025-03-31T12:11:45.408Z","repository":{"id":57321615,"uuid":"62593572","full_name":"trstringer/peacherine","owner":"trstringer","description":":peach: Cross-platform (node.js) and multi-datasource query module","archived":false,"fork":false,"pushed_at":"2016-07-18T18:10:24.000Z","size":27,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T00:39:37.836Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trstringer.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-04T23:56:32.000Z","updated_at":"2021-06-06T15:30:47.000Z","dependencies_parsed_at":"2022-08-25T22:41:36.755Z","dependency_job_id":null,"html_url":"https://github.com/trstringer/peacherine","commit_stats":null,"previous_names":["tstringer/peacherine"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fpeacherine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fpeacherine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fpeacherine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trstringer%2Fpeacherine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trstringer","download_url":"https://codeload.github.com/trstringer/peacherine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246296620,"owners_count":20754634,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T15:05:04.680Z","updated_at":"2025-03-31T12:11:45.381Z","avatar_url":"https://github.com/trstringer.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Peacherine\n\n***The cross-platform and multi-datasource query module***\n\n*Want to see support for another data source type? Open an issue so that it can be prioritized and tracked*\n\n**Future development: continue to add popular database management systems (SQL, NoSQL, whatever...)**\n\n - [Why?](#why)\n - [Install](#install)\n - [Supported data sources](#supported-data-sources)\n   - [SQL Server and SQL Azure](#sql-server-and-sql-azure)\n     - [Run query](#run-query-sql)\n     - [Test connection](#test-connection-sql)\n   - [Azure DocumentDB](#azure-documentdb)\n     - [Query collection](#query-collection-documentdb)\n     - [Insert document](#insert-document-documentdb)\n     - [Test connection](#test-connection-documentdb)\n   - [MongoDB](#mongodb)\n     - [Query collection](#query-all-documents-mongodb)\n     - [Query collection with filter](#query-documents-in-collection-with-filter-mongodb)\n     - [Insert document](#insert-document-mongodb)\n     - [Update document](#update-document-mongodb)\n     - [Delete document](#delete-document-mongodb)\n     - [Test connection](#test-connection-mongodb)\n   - [MySQL](#mysql)\n     - [Run query](#run-query-mysql)\n     - [Test connection](#test-connection-mysql)\n - [Test and contribute](#test)\n\n### Why?\n\nI 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\n\n### Install\n\n```\n$ npm install peacherine\n```\n\n## Supported data sources\n\n### Get supported data sources\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst supportedDataSources = peacherine.getDataSourceTypes();\n// returns a string array of data source types\n```\n\n# SQL Server and SQL Azure\n\n## Run query (SQL)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType = 'mssql',\n  server: '...',\n  database: '...',\n  username: '...',\n  password: '...'\n};\n\nconst actionOptions = {\n  query: 'SELECT object_id, name FROM sys.objects'\n};\n\npeacherine.run(connectionOptions, actionOptions, (err, results) =\u003e {\n  // handle err and results, if any\n});\n```\n\n## Test connection (SQL)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType = 'mssql',\n  server: '...',\n  database: '...',\n  username: '...',\n  password: '...'\n};\n\npeacherine.testConnection(connectionOptions, (err) =\u003e {\n  if (err) {\n    // failed connection\n  }\n  else {\n    // successful connection\n  }\n});\n```\n\n# Azure DocumentDB\n\n## Query collection (DocumentDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'documentdb',\n  endpoint: 'https://...documents.azure.com:.../',\n  key: '...',\n  database: '...'\n};\n\nconst actionOptions = {\n  operation: 'queryCollection',\n  query: 'SELECT * FROM c',\n  collection: 'collection-name'\n};\n\npeacherine.run(connectionOptions, actionOptions, (err, results) =\u003e {\n  // handle err and results\n});\n```\n\n## Insert document (DocumentDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'documentdb',\n  endpoint: 'https://...documents.azure.com:.../',\n  key: '...',\n  database: '...'\n};\n\nconst actionOptions = {\n  operation: 'createDocument',\n  collection: 'collection-name',\n  document: {\n    id: 'some-id',\n    message: 'test document creation'\n  }\n};\n\npeacherine.run(connectionOptions, actionOptions, (err, results) =\u003e {\n  // handle err and results\n});\n```\n\n## Test connection (DocumentDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'documentdb',\n  endpoint: 'https://...documents.azure.com:.../',\n  key: '...',\n  database: '...'\n};\n\npeacherine.testConnection(connectionOptions, (err) =\u003e {\n  if (err) {\n    // failed connection\n  }\n  else {\n    // successful connection\n  }\n});\n```\n\n# MongoDB\n\n## Query all documents (MongoDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'mongodb',\n  host: '...',\n  port: 27017,\n  database: '...'\n};\n\nconst actionOptions = {\n  operation: 'queryCollection',\n  collection: 'collection-name'\n};\n\npeacherine.run(connectionOptions, actionOptions, (err, results) =\u003e {\n  // handle err and results\n});\n```\n\n## Query documents in collection with filter (MongoDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'mongodb',\n  host: '...',\n  port: 27017,\n  database: '...'\n};\n\nconst actionOptions = {\n  operation: 'queryCollection',\n  collection: 'collection-name',\n  filter: {\n    id: 1\n  }\n};\n\npeacherine.run(connectionOptions, actionOptions, (err, results) =\u003e {\n  // handle err and results\n});\n```\n\n## Insert document (MongoDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'mongodb',\n  host: '...',\n  port: 27017,\n  database: '...'\n};\n\nconst actionOptions = {\n  operation: 'createDocument',\n  collection: 'collection-name',\n  document: {\n    id: 1,\n    message: 'test document creation'\n  }\n};\n\npeacherine.run(connectionOptions, actionOptions, (err) =\u003e {\n  // handle err\n});\n```\n\n## Update document (MongoDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'mongodb',\n  host: '...',\n  port: 27017,\n  database: '...'\n};\n\nconst actionOptions = {\n  operation: 'updateDocuments',\n  collection: 'collection-name',\n  filter: {\n    id: 1\n  },\n  updateOptions: {\n    $set: {\n      message: 'my new message'\n    }\n  }\n};\n\npeacherine.run(connectionOptions, actionOptions, (err, result) =\u003e {\n  // handle err and result\n});\n```\n\n## Delete document (MongoDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'mongodb',\n  host: '...',\n  port: 27017,\n  database: '...'\n};\n\nactionOptions = {\n  operation: 'deleteDocuments',\n  collection: 'collection-name',\n  filter: {\n    id: 1\n  }\n};\n\npeacherine.run(connectionOptions, actionOptions, (err, result) =\u003e {\n  // handle err and result\n});\n```\n\n## Test connection (MongoDB)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'mongodb',\n  host: '...',\n  port: 27017,\n  database: '...'\n};\n\npeacherine.testConnection(connectionOptions, (err) =\u003e {\n  if (err) {\n    // failed connection\n  }\n  else {\n    // successful connection\n  }\n});\n```\n\n# MySQL\n\n## Run query (MySQL)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'mysql',\n  server: '...',\n  database: '...',\n  username: '...',\n  password: '...'\n};\n\nconst actionOptions = {\n  query: 'SELECT * FROM information_schema.tables'\n};\n\npeacherine.run(connectionOptions, actionOptions, (err, results) =\u003e {\n  // handle err and results, if any\n});\n```\n\n## Test connection (MySQL)\n\n```javascript\nconst peacherine = require('peacherine');\n\nconst connectionOptions = {\n  dataSourceType: 'mysql',\n  server: '...',\n  database: '...',\n  username: '...',\n  password: '...'\n};\n\npeacherine.testConnection(connectionOptions, (err) =\u003e {\n  if (err) {\n    // failed connection\n  }\n  else {\n    // successful connection\n  }\n});\n```\n\n# Test\n\nWant to contribute?  Clone the repo and use `npm test` to run unit tests\n\n```\n$ git clone https://github.com/tstringer/peacherine.git\n$ cd peacherine\n$ npm install\n$ npm test\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrstringer%2Fpeacherine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrstringer%2Fpeacherine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrstringer%2Fpeacherine/lists"}