petersirka / nosql

NoSQL embedded database for small node.js projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error sorting on Date

tregenza opened this issue · comments

Sorting on a date field in a find() generates an error. Searching on non-date fields works correctly.

Note - this is using the Beta code (2.2?).

Error Message:

info: Processing Queue 6d6fireball
info: find
/var/www/nodes/twittermanager/node_modules/nosql/utils.js:572
			if (!exports.isDate(field))
			             ^

TypeError: exports.isDate is not a function
    at Array.quicksort.Array.orderBy (/var/www/nodes/twittermanager/node_modules/nosql/utils.js:572:17)
    at /var/www/nodes/twittermanager/node_modules/nosql/index.js:568:20
    at Immediate.<anonymous> (/var/www/nodes/twittermanager/node_modules/nosql/index.js:1880:5)
    at runCallback (timers.js:641:20)
    at tryOnImmediate (timers.js:610:5)
    at processImmediate [as _immediateCallback] (timers.js:582:5)

Sample Code:

	winston.log( 'info', "Processing Queue", this.queueScreenName);

        /* Loop Queued Actions */
	var that = this;

	var builderCallbackFunction = function(err,response) {
            winston.log("info","procecssQueue builderCallbackFunction");
	}

	var builderFunction = function(builder) {
		/* No SQL Builder to get elements from queue in oldest first order */
               winston.log("info","find");

		builder.sort('lastActionMoment');
		builder.callback ( builderCallbackFunction );
	}

	this.dbQueue.find().make ( builderFunction );

Sample Data

{"action":"mystats","minTimeSecs":3600,"lastActionMoment":"2016-11-23T11:42:54.301Z"}
{"action":"mystats","minTimeSecs":3600,"lastActionMoment":"2016-11-23T11:42:54.301Z"}

Hi @tregenza, I'll fix it today. I have added a lot of new features into the Total.js NoSQL embedded version for the moment.

New features:

  • in-memory mode (developer can enable this mode for the whole DB or for a custom views)
  • join joining data between different databases
  • scalar operations min, max, avg, sum, group and count
  • dates can be selected by month, year or day

https://github.com/totaljs/framework/blob/v2.3.0/changes.txt#L17

:-) I have to add all new features here.
Thank you!

I have published a new beta with all new features.
Please try it 👍

Thank you!

That fix it!

Some of those new features look very useful. I'll be trying them soon.