Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: persist is not defined #5

Closed
thelonious opened this issue Nov 6, 2013 · 2 comments
Closed

ReferenceError: persist is not defined #5

thelonious opened this issue Nov 6, 2013 · 2 comments

Comments

@thelonious
Copy link

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

@notheotherben
Copy link
Owner

Hi Kevin,
Thanks for the bug report - was caused by a quick edit I made to the code to add the option of not persisting timestamps to the database (for example, in a server environment where you wish to keep track of the last modification date for objects in memory).

I've fixed the issue in v0.2.1.

Enjoy 😄

@thelonious
Copy link
Author

Works great! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants