diff --git a/API.md b/API.md index f2be412..70e758d 100644 --- a/API.md +++ b/API.md @@ -4,7 +4,7 @@ Class for connection management **Parameters** -- `config` +- `config` **object** connection parameters ## constructor @@ -12,7 +12,28 @@ Constructor **Parameters** -- `config` **object** connection paramaters +- `config` **object** connection parameters + +**Examples** + +```javascript +let nodeQuery = require('ci-node-query')({ + driver: 'mysql', + connection: { + host: 'localhost', + user: 'root', + password: '', + database: 'mysql' + } +}); +``` + +```javascript +let nodeQuery = require('ci-node-query')({ + driver: 'sqlite', + connection: ':memory:' +}); +``` ## getQuery @@ -368,7 +389,7 @@ Returns **QueryBuilder** The Query Builder object, for chaining ## query -Manually make an sql query +Run an arbitrary sql query. Run as a prepared statement. **Parameters** @@ -500,3 +521,24 @@ Set a 'where not in' clause - `values` **Array** the array of items to search in Returns **QueryBuilder** The Query Builder object, for chaining + +# Result + +Query result object + +**Parameters** + +- `rows` **Array** the data rows of the result +- `columns` **Array** the column names in the result + +## columnCount + +Get the number of columns returned by the query + +Returns **Number** the number of columns in the result + +## rowCount + +Get the number of rows returned by the query + +Returns **Number** the number of rows in the result diff --git a/CHANGELOG.md b/CHANGELOG.md index f072bbf..94b7191 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * Changed connection setup to just use a config object - the appropriate adapter object is created by the library. * Removed mysql adapter, as mysql2 is very similar and does proper prepared statements * Removed firebird entirely +* Created a standard result object ## 3.2.0 * Added public `query` method for making arbitrary sql calls diff --git a/README.md b/README.md index 00119bf..e0e5b3c 100755 --- a/README.md +++ b/README.md @@ -46,8 +46,8 @@ query.select('foo') .join('baz', 'baz.boo = bar.foo', 'left') .orderBy('x', 'DESC') .limit(2, 3) - .get(function(/* Adapter dependent arguments */) { - // Database module result handling + .get(function(err, result) { + // Handle Results Here }); // As of version 3.1.0, you can also get promises @@ -65,6 +65,26 @@ queryPromise.then(function(res) { }); ``` +### Result object +As of version 4, all adapters return a standard result object, which looks similar to this: + +```javascript +// Result object +{ + rows: [{ + columnName1: value1, + columnName2: value2, + }], + + columns: ['column1', 'column2'], +} +``` + +In addition to the rows, and columns properties, +the result object has two methods, `rowCount` and `columnCount`. +These methods return the number of rows and columns columns in the current result. + + ### Security notes As of version 2, `where` and `having` type methods parse the values passed to look for function calls. While values passed are still passed as query parameters, take care to avoid passing these kinds of methods unfiltered input. SQL function arguments are not currently parsed, so they need to be properly escaped for the current database. diff --git a/docs/assets/fonts/source-code-pro/LICENSE.txt b/docs/assets/fonts/source-code-pro/LICENSE.txt new file mode 100755 index 0000000..d154618 --- /dev/null +++ b/docs/assets/fonts/source-code-pro/LICENSE.txt @@ -0,0 +1,93 @@ +Copyright 2010, 2012 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/assets/fonts/source-code-pro/README.md b/docs/assets/fonts/source-code-pro/README.md new file mode 100755 index 0000000..20be1f3 --- /dev/null +++ b/docs/assets/fonts/source-code-pro/README.md @@ -0,0 +1,20 @@ +# Source Code Pro + +Source Code Pro is a set of OpenType fonts that have been designed to work well +in user interface (UI) environments. In addition to a functional OpenType font, this open +source project provides all of the source files that were used to build this OpenType font +by using the AFDKO makeotf tool. + +## Font installation instructions + +* [Mac OS X](http://support.apple.com/kb/HT2509) +* [Windows](http://windows.microsoft.com/en-us/windows-vista/install-or-uninstall-fonts) +* [Linux/Unix-based systems](https://github.com/adobe-fonts/source-code-pro/issues/17#issuecomment-8967116) + +## Getting Involved + +Send suggestions for changes to the Source Code OpenType font project maintainer, [Paul D. Hunt](mailto:opensourcefonts@adobe.com?subject=[GitHub] Source Code Pro), for consideration. + +## Further information + +For information about the design and background of Source Code, please refer to the [official font readme file](http://www.adobe.com/products/type/font-information/source-code-pro-readme.html). diff --git a/docs/assets/fonts/source-code-pro/WOFF/OTF/SourceCodePro-Regular.otf.woff b/docs/assets/fonts/source-code-pro/WOFF/OTF/SourceCodePro-Regular.otf.woff new file mode 100755 index 0000000..395436e Binary files /dev/null and b/docs/assets/fonts/source-code-pro/WOFF/OTF/SourceCodePro-Regular.otf.woff differ diff --git a/docs/assets/fonts/source-code-pro/source-code-pro.css b/docs/assets/fonts/source-code-pro/source-code-pro.css new file mode 100755 index 0000000..842b232 --- /dev/null +++ b/docs/assets/fonts/source-code-pro/source-code-pro.css @@ -0,0 +1,15 @@ +@font-face{ + font-family: 'Source Code Pro'; + font-weight: 400; + font-style: normal; + font-stretch: normal; + src: url('WOFF/OTF/SourceCodePro-Regular.otf.woff') format('woff'); +} + +@font-face{ + font-family: 'Source Code Pro'; + font-weight: 500; + font-style: normal; + font-stretch: normal; + src: url('WOFF/OTF/SourceCodePro-Medium.otf.woff') format('woff'); +} diff --git a/docs/assets/fonts/source-sans-pro/LICENSE.txt b/docs/assets/fonts/source-sans-pro/LICENSE.txt new file mode 100755 index 0000000..87ec82c --- /dev/null +++ b/docs/assets/fonts/source-sans-pro/LICENSE.txt @@ -0,0 +1,93 @@ +Copyright 2010, 2012, 2014 Adobe Systems Incorporated (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe Systems Incorporated in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/docs/assets/fonts/source-sans-pro/README.md b/docs/assets/fonts/source-sans-pro/README.md new file mode 100755 index 0000000..a3e1b9d --- /dev/null +++ b/docs/assets/fonts/source-sans-pro/README.md @@ -0,0 +1,20 @@ +# Source Sans Pro + +Source Sans Pro is a set of OpenType fonts that have been designed to work well +in user interface (UI) environments. In addition to a functional OpenType font, this open +source project provides all of the source files that were used to build this OpenType font +by using the AFDKO makeotf tool. + +## Font installation instructions + +* [Mac OS X](http://support.apple.com/kb/HT2509) +* [Windows](http://windows.microsoft.com/en-us/windows-vista/install-or-uninstall-fonts) +* [Linux/Unix-based systems](https://github.com/adobe-fonts/source-code-pro/issues/17#issuecomment-8967116) + +## Getting Involved + +Send suggestions for changes to the Source Sans OpenType font project maintainer, [Paul D. Hunt](mailto:opensourcefonts@adobe.com?subject=[GitHub] Source Sans Pro), for consideration. + +## Further information + +For information about the design and background of Source Sans, please refer to the [official font readme file](http://www.adobe.com/products/type/font-information/source-sans-pro-readme.html). diff --git a/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Bold.otf.woff b/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Bold.otf.woff new file mode 100755 index 0000000..6700893 Binary files /dev/null and b/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Bold.otf.woff differ diff --git a/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Light.otf.woff b/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Light.otf.woff new file mode 100755 index 0000000..10490ec Binary files /dev/null and b/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Light.otf.woff differ diff --git a/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Regular.otf.woff b/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Regular.otf.woff new file mode 100755 index 0000000..04739e7 Binary files /dev/null and b/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Regular.otf.woff differ diff --git a/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Semibold.otf.woff b/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Semibold.otf.woff new file mode 100755 index 0000000..17d744d Binary files /dev/null and b/docs/assets/fonts/source-sans-pro/WOFF/OTF/SourceSansPro-Semibold.otf.woff differ diff --git a/docs/assets/fonts/source-sans-pro/bower.json b/docs/assets/fonts/source-sans-pro/bower.json new file mode 100755 index 0000000..dfe14f2 --- /dev/null +++ b/docs/assets/fonts/source-sans-pro/bower.json @@ -0,0 +1,17 @@ +{ + "name": "source-sans-pro", + "version": "2.020R-ro/1.075R-it", + "main": "source-sans-pro.css", + "homepage": "https://github.com/adobe-fonts/source-sans-pro", + "repository": { + "type": "git", + "url": "https://github.com/adobe-fonts/source-sans-pro.git" + }, + "authors": [ + { "name": "Paul D. Hunt" } + ], + "description": "Source Sans Pro font family by Adobe", + "license": "SIL OFL 1.1", + "keywords": ["font", "sourcesans", "sourcesanspro", "source sans", "source sans pro"], + "ignore": ["**/.*"] +} diff --git a/docs/assets/fonts/source-sans-pro/source-sans-pro.css b/docs/assets/fonts/source-sans-pro/source-sans-pro.css new file mode 100755 index 0000000..6d3862c --- /dev/null +++ b/docs/assets/fonts/source-sans-pro/source-sans-pro.css @@ -0,0 +1,31 @@ +@font-face{ + font-family: 'Source Sans Pro'; + font-weight: 300; + font-style: normal; + font-stretch: normal; + src: url('WOFF/OTF/SourceSansPro-Light.otf.woff') format('woff'); +} + +@font-face{ + font-family: 'Source Sans Pro'; + font-weight: 400; + font-style: normal; + font-stretch: normal; + src: url('WOFF/OTF/SourceSansPro-Regular.otf.woff') format('woff'); +} + +@font-face{ + font-family: 'Source Sans Pro'; + font-weight: 600; + font-style: normal; + font-stretch: normal; + src: url('WOFF/OTF/SourceSansPro-Semibold.otf.woff') format('woff'); +} + +@font-face{ + font-family: 'Source Sans Pro'; + font-weight: 700; + font-style: normal; + font-stretch: normal; + src: url('WOFF/OTF/SourceSansPro-Bold.otf.woff') format('woff'); +} diff --git a/docs/index.html b/docs/index.html index 151689e..9d2aa12 100644 --- a/docs/index.html +++ b/docs/index.html @@ -242,6 +242,21 @@ class='regular block'> #whereNotIn + + Result + + + #columnCount + + + #rowCount + @@ -255,10 +270,11 @@

Parameters

@@ -285,11 +301,24 @@
  • object config :
    -

    connection paramaters

    +

    connection parameters

  • +

    Examples

    +
    let nodeQuery = require('ci-node-query')({
    +            	driver: 'mysql',
    +            	connection: {
    +            		host: 'localhost',
    +            		user: 'root',
    +            		password: '',
    +            		database: 'mysql'
    +            	}
    +            });
    let nodeQuery = require('ci-node-query')({
    +            	driver: 'sqlite',
    +            	connection: ':memory:'
    +            });
    @@ -1604,7 +1633,7 @@ prefixed with 'OR NOT'

    #query(sql, [params], [callback])
    -

    Manually make an sql query

    +

    Run an arbitrary sql query. Run as a prepared statement.

    @@ -1613,7 +1642,7 @@ prefixed with 'OR NOT'

    query(sql, [params], [callback])

    -

    Manually make an sql query

    +

    Run an arbitrary sql query. Run as a prepared statement.

    Parameters