Comparing version 0.0.1 to 0.0.2
var Server = require('../'); | ||
var Memory = require('../lib/memory'); | ||
// Create server, | ||
// Create server. | ||
var server = new Server(); | ||
@@ -23,20 +23,22 @@ | ||
// Get 'contact' model. | ||
var Contact = server.model('contact'); | ||
server.init(function() { | ||
// Get 'contact' model. | ||
var Contact = server.model('contact'); | ||
// Create 'john' contact instance. | ||
var john = new Contact({ | ||
id: 1, | ||
name: 'John', | ||
email: 'john@example.com' | ||
}); | ||
// Create 'john' contact instance. | ||
var john = new Contact({ | ||
id: 1, | ||
name: 'John', | ||
email: 'john@example.com' | ||
}); | ||
// Save contact. | ||
john.save(function (error, john) { | ||
console.log(john); | ||
// Save contact. | ||
john.save(function (error, john) { | ||
console.log(john); | ||
// Get a list of contacts. | ||
Contact.list({}, function (error, contacts) { | ||
console.log(contacts); | ||
}) | ||
// Get a list of contacts. | ||
Contact.list({}, function (error, contacts) { | ||
console.log(contacts); | ||
}); | ||
}); | ||
}); |
10
index.js
@@ -84,2 +84,5 @@ var url = require('url'); | ||
// Add name to model settings. | ||
settings.name = name; | ||
this.storage.model(name, Model.compile(connection, settings)); | ||
@@ -103,3 +106,3 @@ | ||
port: 'port', | ||
path: 'pathname' | ||
database: 'pathname' | ||
}; | ||
@@ -116,2 +119,7 @@ | ||
if (property == 'pathname') { | ||
// Remove slash from pathname. | ||
value = value.substring(1, value.length); | ||
} | ||
if (property in urlInfo) { | ||
@@ -118,0 +126,0 @@ settings[setting] = value; |
@@ -21,2 +21,9 @@ /* | ||
/** | ||
* Initialize database connection. | ||
*/ | ||
MemoryAdapter.prototype.init = function(callback) { | ||
callback(); | ||
}; | ||
/** | ||
* List stored items. | ||
@@ -23,0 +30,0 @@ * |
{ | ||
"name": "xylem", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Cross database object persistence for Node.js.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -11,11 +11,7 @@ # Xylem | ||
``` | ||
npm install xylem | ||
``` | ||
$ npm install xylem | ||
### Installing an adapter | ||
``` | ||
npm install xylem-mongodb | ||
``` | ||
$ npm install xylem-mongodb | ||
@@ -25,5 +21,7 @@ ### Creating connections | ||
```js | ||
var server = require('xylem'); | ||
var Server = require('xylem'); | ||
var MongoDB = require('xylem-mongodb'); | ||
var server = new Server(); | ||
server | ||
@@ -65,3 +63,3 @@ .adapter('mongodb', MongoDB) | ||
console.log(contacts); | ||
}) | ||
}); | ||
}); | ||
@@ -75,3 +73,3 @@ ``` | ||
- Memory (Built in) | ||
- MongoDB | ||
- [MongoDB](https://github.com/recidive/xylem-mongodb) | ||
@@ -78,0 +76,0 @@ ## Lifecycle callbacks |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18983
587
102