Giter Club home page Giter Club logo

node-orm-timestamps's People

Contributors

ajostergaard avatar limianwang avatar notheotherben avatar spartan563 avatar zlotnika avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

node-orm-timestamps's Issues

ReferenceError: persist is not defined

I'm running node v0.10.21, orm v2.1.3, orm-timestamps v0.2.0. I'm mostly following the example code:

app.use(orm.express(config.mysql, {
    define: function(db, models) {
        db.use(modts);

        var user = db.define('user', {
            username: String,
            email: String,
            password: String
        }, {
            timestamp: true
        });

        user.sync(function(err) {
            if (err) {
                console.error("error creating user model: " + err);
            }
        });
    }
}));

and I get the resulting exception:

ReferenceError: persist is not defined
    at Object.monitor [as beforeDefine] (/Users/kevin/Documents/Projects/node/timestamp/node_modules/orm-timestamps/lib/orm-timestamps.js:48:6)
    at ORM.define (/Users/kevin/Documents/Projects/node/timestamp/node_modules/orm/lib/ORM.js:213:20)
    at Object.app.use.orm.express.define (/Users/kevin/Documents/Projects/node/timestamp/app.js:40:23)
    at /Users/kevin/Documents/Projects/node/timestamp/node_modules/orm/lib/Express.js:38:9
    at Handshake._callback (/Users/kevin/Documents/Projects/node/timestamp/node_modules/orm/lib/ORM.js:127:13)
    at Handshake.Sequence.end (/Users/kevin/Documents/Projects/node/timestamp/node_modules/mysql/lib/protocol/sequences/Sequence.js:75:24)
    at Handshake.Sequence.OkPacket (/Users/kevin/Documents/Projects/node/timestamp/node_modules/mysql/lib/protocol/sequences/Sequence.js:84:8)
    at Protocol._parsePacket (/Users/kevin/Documents/Projects/node/timestamp/node_modules/mysql/lib/protocol/Protocol.js:172:24)
    at Parser.write (/Users/kevin/Documents/Projects/node/timestamp/node_modules/mysql/lib/protocol/Parser.js:62:12)
    at Protocol.write (/Users/kevin/Documents/Projects/node/timestamp/node_modules/mysql/lib/protocol/Protocol.js:37:16)

This is the line in orm-timestamps:

if(persist && options.createdProperty !== false)

I don't see 'persist' defined in the module itself, so that may be the issue here. Just for testing purposes, I added "var persist = true" after "options" is extend and that resolved the issue for me.

Thanks,
Kevin

Timestamps Saving Incorrect Times

Using package version 0.1.1, node version 0.10.17 and postgres version 9.1.9 I'm experiencing an issue with incorrect timestamps.

I changed nothing from the default configuration for the package and yet timestamps still appear to be exactly 7 hours ahead of local time. For instance, new Date() reports the correct time at Thu Sep 05 2013 09:11:14 GMT-0700 (PDT). Running SELECT NOW() on my postgres instance also returns the expected time PDT. However, creating and saving a timestamped ORM model instance and then immediately reloading it gives it a created_at property of Thu Sep 05 2013 16:11:14 GMT-0700 (PDT) which is not PDT but GMT-0.

If new Date() is the default source of date and time information for timestamps, why are my timestamps in GMT-0?

Deleted timestamp

Just a suggestion, maybe add functionality for 'soft deletes', which will be updated when the row is 'deleted', then excluded from further searches (unless set to include deleted entries)

expiry/expire naming conflict

Line 8 reads:
expiry: function() { var d = new Date(); d.setMinutes(d.getMinutes() + 60); return d; },

Later this is executed with options.expire(). I presume it should also read "expiry" in line 8.

Bug in persist timestamps

Hi
when i set persist to true orm-timestamp throws a "Maximum call stack size exceeded" error

Here is full stack trace and error:

(node:7632) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): RangeError: Maximum call stack size exceeded
(node:7632) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the
 Node.js process with a non-zero exit code.
RangeError: Maximum call stack size exceeded
    at Object.now (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:7:16)
    at Object.<anonymous> (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:81:46)
    at Object.exports.wait (C:\actcustomer\node_modules\orm\lib\Hook.js:19:26)
    at saveInstanceProperty (C:\actcustomer\node_modules\orm\lib\Instance.js:422:10)
    at Object.set [as modified_at] (C:\actcustomer\node_modules\orm\lib\Instance.js:521:11)
    at Object.<anonymous> (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:81:36)
    at Object.exports.wait (C:\actcustomer\node_modules\orm\lib\Hook.js:19:26)
    at saveInstanceProperty (C:\actcustomer\node_modules\orm\lib\Instance.js:422:10)
    at Object.set [as modified_at] (C:\actcustomer\node_modules\orm\lib\Instance.js:521:11)
    at Object.<anonymous> (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:81:36)
    at Object.exports.wait (C:\actcustomer\node_modules\orm\lib\Hook.js:19:26)
    at saveInstanceProperty (C:\actcustomer\node_modules\orm\lib\Instance.js:422:10)
    at Object.set [as modified_at] (C:\actcustomer\node_modules\orm\lib\Instance.js:521:11)
    at Object.<anonymous> (C:\actcustomer\node_modules\orm-timestamps\lib\orm-timestamps.js:81:36)
    at Object.exports.wait (C:\actcustomer\node_modules\orm\lib\Hook.js:19:26)
    at saveInstanceProperty (C:\actcustomer\node_modules\orm\lib\Instance.js:422:10)
Maximum call stack size exceeded

created_at and updated_at not working

I added this code in my project:

var orm = require("orm");
var modts = require('orm-timestamps');
orm.settings.set("instance.returnAllErrors", true);
orm.settings.set("connection.reconnect", true);
orm.settings.set("connection.pool", true);
orm.settings.set("connection.debug", true);
orm.connect("mysql://root:@localhost/laser_control", function (err, db) {
	if (err) throw err;	
           db.use(modts);

           var user = db.define("users", {
			id			: {type: 'serial'},
			name		: { type: 'text', required : true},
			mail		: { type: 'text', unique: true, required : true},
			password	: { type: 'text', required : true},
			crm			: { type: 'integer', key: true },
			city		: { type: 'text', key: true, size: 2},
			id_socket	: { type: 'text', size: 100},
			status		: { type: "enum", values: [ "1", "0"], defaultValue: "1" },
		}, {
			timestamp: true
		});

	db.sync(function(err) {
		if (err) throw err;
	});
});

--

it create all my model including created_at and updated_at, but everytime that i insert a new user, my fields created_at and updated_at keep the value "NULL" in database, i'm doing something wrong ?

obs: my code isn't give any error, it just not fill with the values that i want.

Read-only timestamps

This would be cool but not mandatory. Perhaps it needs some more integration between plugins and models/instances.

The idea would be to have the possibility to read this methods but not change them.

Is it possible to use timestamp in MySQL

I'm pretty sure I know the answer to this already, but I have to ask :) Is there any way to use "timestamp" as the column type for MySQL? I prefer using that type because it is timezone independent. I've hacked orm to allow this type for MySQL, but I'd much rather use this nice plugin instead.

Thanks!
Kevin

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.