Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: chrisdew/subsql
base: 7e45975784
...
head fork: chrisdew/subsql
compare: 8b2cd1aa22
  • 3 commits
  • 9 files changed
  • 0 commit comments
  • 2 contributors
View
30 lib/database.js
@@ -0,0 +1,30 @@
+// This class represents a Database
+
+var util = require('util');
+var events = require('events');
+var table = require('./table');
+
+exports.hello = hello;
+exports.Database = Database;
+
+function hello() {
+ return "hello database";
+}
+
+function Database() {
+ this.tablesByName = {};
+}
+
+util.inherits(Database, events.EventEmitter);
+
+Database.prototype.createTable = function(tableSpec) {
+ this.tablesByName[tableSpec.name] = new table.Table(tableSpec);
+ //console.log(this);
+ this.emit('createTable', tableSpec);
+ return this;
+}
+
+
+Database.prototype.executeJson = function(json) {
+
+}
View
15 lib/row.js
@@ -0,0 +1,15 @@
+var util = require('util');
+var events = require('events');
+
+exports.hello = hello;
+exports.Row = Row;
+
+function hello() {
+ return "hello row";
+}
+
+function Row() {
+ this._version = 1;
+}
+
+util.inherits(Row, events.EventEmitter);
View
23 lib/table.js
@@ -0,0 +1,23 @@
+// This class represents a Database
+
+var util = require('util');
+var events = require('events');
+
+exports.hello = hello;
+exports.Table = Table;
+
+function hello() {
+ return "hello table";
+}
+
+
+function Table(tableSpec) {
+ for (var p in tableSpec) {
+ this[p] = tableSpec[p];
+ }
+ this.rowsByPk = {};
+ this.pkName = null;
+ this.nextPk = 1;
+}
+
+util.inherits(Table, events.EventEmitter);
View
5 package.json
@@ -2,7 +2,7 @@
"author": "Chris Dew <chris.dew@barricane.com> (http://www.chrisdew.com)",
"name": "subsql",
"description": "An SQL Database with Subscribed Queries",
- "version": "0.0.2",
+ "version": "0.0.3",
"homepage": "https://github.com/chrisdew/subsql",
"repository": {
"type": "git",
@@ -16,7 +16,8 @@
"express": "~3.0.3",
"telnet": "0.0.1",
"pegjs": "0.7.0",
- "jscoverage": "~0.2.5"
+ "jscoverage": "~0.2.5",
+ "socket.io": "~0.9.11"
},
"devDependencies": {
"mocha": "~1.7.0"
View
32 test/database-test.js
@@ -0,0 +1,32 @@
+var assert = require("assert")
+
+var database = require('../lib/database.js');
+describe('Database', function() {
+ it('should say "hello database"', function() {
+ assert.equal("hello database", database.hello());
+ });
+ it('should create an instance"', function() {
+ assert.deepEqual({tablesByName:{}}, new database.Database());
+ });
+ it('should be an instance of event emitter', function() {
+ assert.deepEqual("EventEmitter",
+ new database.Database().constructor.super_.name);
+ });
+ it('should create a table called mytable', function() {
+ assert.deepEqual( { tablesByName: { mytable: { name: "mytable"
+ , fields: [ { field: "id", type: "integer", pk: true, ai: true }
+ , { field: "foo", type: "varchar"}
+ ]
+ , rowsByPk: {}
+ , pkName: null
+ , nextPk: 1
+ } } }
+ , new database.Database().createTable(
+ { name:"mytable"
+ , fields:[ { field: 'id', type: 'integer', pk:true, ai:true }
+ , { field: 'foo', type: 'varchar' }
+ ]
+ } ) );
+ });
+});
+
View
9 test/index-test.js
@@ -0,0 +1,9 @@
+var assert = require("assert")
+
+var subsql = require('../index.js');
+describe('SubSQL', function() {
+ it('should say "hello world"', function() {
+ assert.equal("hello world", subsql.helloWorld());
+ });
+});
+
View
15 test/test.js → test/parser-test.js
@@ -1,19 +1,4 @@
var assert = require("assert")
-describe('Array', function(){
- describe('#indexOf()', function(){
- it('should return -1 when the value is not present', function(){
- assert.equal(-1, [1,2,3].indexOf(5));
- assert.equal(-1, [1,2,3].indexOf(0));
- })
- })
-})
-
-var subsql = require('../index.js');
-describe('SubSQL', function() {
- it('should say "hello world"', function() {
- assert.equal("hello world", subsql.helloWorld());
- });
-});
var peg = require('pegjs');
var fs = require('fs');
View
16 test/row-test.js
@@ -0,0 +1,16 @@
+var assert = require("assert")
+
+var row = require('../lib/row.js');
+describe('Row', function() {
+ it('should say "hello row"', function() {
+ assert.equal("hello row", row.hello());
+ });
+ it('should create an instance"', function() {
+ assert.deepEqual({"_version": 1}, new row.Row());
+ });
+ it('should be an instance of event emitter', function() {
+ assert.deepEqual("EventEmitter",
+ new row.Row().constructor.super_.name);
+ });
+});
+
View
16 test/table-test.js
@@ -0,0 +1,16 @@
+var assert = require("assert")
+
+var table = require('../lib/table.js');
+describe('Table', function() {
+ it('should say "hello table"', function() {
+ assert.equal("hello table", table.hello());
+ });
+ it('should create an instance"', function() {
+ assert.deepEqual({"rowsByPk":{},"pkName":null,"nextPk":1}, new table.Table());
+ });
+ it('should be an instance of event emitter', function() {
+ assert.deepEqual("EventEmitter",
+ new table.Table().constructor.super_.name);
+ });
+});
+

No commit comments for this range

Something went wrong with that request. Please try again.