Permalink
Browse files

first commit

  • Loading branch information...
Alex Young
Alex Young committed May 26, 2011
0 parents commit 91355c5f2dca9addb49ea634cb85565f4cf8cc86
Showing with 2,845 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +19 −0 Makefile
  3. +88 −0 README.md
  4. +24 −0 docs/chain_parse.txt
  5. +32 −0 docs/databases.txt
  6. +577 −0 docs/index.html
  7. +58 −0 docs/intro.md
  8. +123 −0 docs/notes.txt
  9. +101 −0 docs/scraps.txt
  10. +2 −0 index.js
  11. +121 −0 lib/chain.js
  12. +74 −0 lib/drivers/couchdb.js
  13. +131 −0 lib/drivers/memory.js
  14. +167 −0 lib/drivers/mongodb.js
  15. +210 −0 lib/drivers/mysql.js
  16. +353 −0 lib/select.js
  17. +42 −0 lib/selector_parser.js
  18. +10 −0 lib/states.js
  19. +11 −0 package.json
  20. +6 −0 test/core_test.js
  21. +201 −0 test/memory_test.js
  22. +238 −0 test/mongodb_test.js
  23. +253 −0 test/mysql_test.js
@@ -0,0 +1,4 @@
+*.swp
+*.swo
+.DS_Store
+node_modules/*
@@ -0,0 +1,19 @@
+all: test docs
+
+test:
+ @node_modules/whiskey/bin/whiskey --tests "test/memory_test.js test/mongodb_test.js test/mysql_test.js test/core_test.js" --print-stdout
+
+testmongo:
+ @node_modules/whiskey/bin/whiskey --tests "test/mongodb_test.js" --print-stdout --verbosity 2
+
+testmysql:
+ @node_modules/whiskey/bin/whiskey --tests "test/mysql_test.js" --print-stdout --verbosity 2
+
+testmemory:
+ @node_modules/whiskey/bin/whiskey --tests "test/memory_test.js" --print-stdout --verbosity 2
+
+docs:
+ @dox --title select lib/select.js -i docs/intro.md > docs/index.html
+
+.PHONY: test docs
+.SILENT: docs
@@ -0,0 +1,88 @@
+# select
+
+`select` is a database library.
+
+Supported databases:
+
+* MySQL
+* MongoDB
+* Memory
+* CouchDB (partial)
+* Planned: PostgreSQL, SQLite
+* Researching: Riak, Redis, selector language
+
+## Installation
+
+ $ npm install select
+
+## Examples
+
+ // Find some items and iterate
+ select('users')
+ .find({ name: 'Alex' })
+ .limit(3)
+ .offset(8)
+ .each(function(index) {
+ console.log(this);
+ });
+
+ // Update an attribute
+ select('users')
+ .find(17)
+ .attr({ name: 'Yuka' });
+
+ // Create
+ select('users')
+ .add({
+ name: 'Bob',
+ email: 'bob@example.com'
+ });
+
+ // Delete
+ select('users')
+ .find(1)
+ .del();
+
+ // Selector language
+ select('users[name="Alex", email="alex@example.com"]').
+ values(function(values) {});
+
+## Philosophy
+
+`select` is:
+
+* A quick way of using common database features
+* Easy to learn for JavaScript developers
+* Easy to extend
+
+`select` is not:
+
+* For building schemas
+* An ORM
+* A validation library
+
+## License
+
+(The MIT License)
+
+Copyright (c) 2011 Alex R. Young
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
@@ -0,0 +1,24 @@
+select('collection').
+ find(params).
+ count(100).
+ offset(10).
+ (attr|del|each) =>
+
+
+attr/del/each = execute (initiates chain parsing, then evaluates)
+
+stack =>
+ find params |
+ count |
+ offset |
+ del |
+
+execution expression: del
+finder: params + count + offset
+
+evaluates => bulk delete for params, count offset
+
+driver: bulkDelete:
+ SQL: DELETE FROM collection WHERE params count offset
+ mongodb: delete based on values
+
@@ -0,0 +1,32 @@
+COUCHDB
+
+* https://github.com/creationix/couch-client
+* Difficulty: high
+* select param: design/view name
+* TODO: is convienient searching on a key=value possible?
+
+MONGODB
+
+* https://github.com/christkv/node-mongodb-native
+* Difficulty: low
+* select param: selector language
+* TODO: find all, find int/string, offset, raw
+
+MYSQL
+
+* https://github.com/felixge/node-mysql
+* Difficulty: low
+* select param: selector language
+* TODO: tests
+
+POSTGRES
+
+* https://github.com/brianc/node-postgres
+
+REDIS
+
+RIAK
+
+SQLITE
+
+* https://github.com/pkrumins/node-sqlite
Oops, something went wrong.

0 comments on commit 91355c5

Please sign in to comment.