Created
November 7, 2012 20:21
-
-
Save booo/4034152 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Batch | |
| constructor: (@keyspace) -> | |
| @statements = [] #list of statements aka insert delete update | |
| toCQL: -> | |
| "BEGIN BATCH | |
| #{(stmt.toCQL() for stmt in @statements).join "\n"} | |
| APPLY BATCH" | |
| class Table | |
| constructor: (@name, @columns, @primaryKeys, @options) -> | |
| create: -> | |
| "CREATE TABLE #{@name} (#{ ("#{name} #{type}" for [name, type] in @columns).join ", " } PRIMARY KEY(#{@primaryKeys.join ", "}))" | |
| drop: -> | |
| "DROP TABLE #{@name}" | |
| truncate: -> | |
| "TRUNCATE TABLE #{@name}" | |
| select: (columns) -> | |
| new SelectStatement @ | |
| insert: -> | |
| update: @insert | |
| delete: -> | |
| class SelectStatement | |
| constructor: (@table, @columns) -> | |
| toCQL: -> | |
| bar = new Table "bar", [["user_id", "varchar"],["tweet_id", "varchar"]], ["user_id"] | |
| b = new Batch("foo") | |
| console.log b.toCQL() | |
| console.log bar.create() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment