Permalink
Browse files

Refactor lazy -> lazy-array

  • Loading branch information...
1 parent ad5ceff commit 339896a9fdf29c3249a59be19edcc4ae26a7946a @kriszyp kriszyp committed Feb 16, 2010
View
1 engines/node/lib/store/sql-engine.js
@@ -5,7 +5,6 @@
*/
-var extendSome = require("lazy").extendSome;
exports.SQLDatabase = function(parameters){
var connectionProvider;
if(parameters.type == "postgres"){
View
6 engines/rhino/lib/store/full-text.js
@@ -1,4 +1,4 @@
-var extendSome = require("lazy").extendSome;
+var LazyArray = require("lazy-array").LazyArray;
var FullText = exports.FullText = function(store, name){
searcher = new org.persvr.store.LuceneSearch("lucene/" + name);
var defaultPut = store.put;
@@ -9,12 +9,12 @@ var FullText = exports.FullText = function(store, name){
return id;
};
store.fulltext = function(query, field, options){
- var idResults = extendSome(searcher.query(query, field, options.start || 0, options.end || 100000000, null));
+ var idResults = LazyArray(searcher.query(query, field, options.start || 0, options.end || 100000000, null));
return {
query: "?id.in(" + idResults.join(",") + ")",
totalCount: idResults.totalCount
};
- /*return extendSome({
+ /*return LazyArray({
some: function(callback){
idResults.some(function(id){
try{
View
4 engines/rhino/lib/store/sql-engine.js
@@ -4,7 +4,7 @@
*/
-var extendSome = require("lazy").extendSome;
+var LazyArray = require("lazy-array").LazyArray;
var drivers = {
mysql: "com.mysql.jdbc.Driver",
sqlite: "org.sqlite.JDBC",
@@ -23,7 +23,7 @@ exports.SQLDatabase = function(parameters){
executeSql: function(query, parameters){
// should roughly follow executeSql in http://www.w3.org/TR/webdatabase/
var rawResults = adapter.executeSql(query, parameters);
- var results = {rows:extendSome(rawResults)};
+ var results = {rows:LazyArray(rawResults)};
if(rawResults.insertId){
results.insertId = rawResults.insertId;
}
View
7 lib/store/readonly-memory.js
@@ -2,7 +2,7 @@
* An readonly in-memory store.
*/
var executeQuery = require("../resource-query").executeQuery;
-var extendSome = require("lazy").extendSome;
+var LazyArray = require("lazy-array").LazyArray;
function MemoryObject(){}
MemoryObject.prototype = {
getId: function(object){
@@ -33,7 +33,7 @@ exports.ReadonlyMemory = function(options){
}
var result = executeQuery(query, options, all);
// make a copy
- return extendSome({
+ return LazyArray({
some: function(callback){
result.some(function(item){
var object = {};
@@ -45,7 +45,8 @@ exports.ReadonlyMemory = function(options){
return callback(object);
});
},
- length: result.length
+ length: result.length,
+ totalCount: result.totalCount
});
}
};
View
6 lib/store/sql.js
@@ -5,7 +5,7 @@
* based on http://www.w3.org/TR/webdatabase/
*/
var SQLDatabase = require("./sql-engine").SQLDatabase;
-var first = require("lazy").first;
+var first = require("lazy-array").first;
var AutoTransaction = require("../stores").AutoTransaction;
var parseQuery = require("../resource-query").parseQuery;
var defineProperty = require("es5-helper").defineProperty;
@@ -29,8 +29,8 @@ exports.SQLStore = function(config){
"delete": function(id){
store.executeSql("DELETE FROM " + config.table + " WHERE " + config.idColumn + "=?", [id]);
},
- put: function(object, id){
- id = id || object[config.idColumn];
+ put: function(object, metadata){
+ id = metadata.id || object[config.idColumn];
if(id !== undefined){
if(!this.get(id)){
id = undefined;

0 comments on commit 339896a

Please sign in to comment.