Skip to content
This repository

Fixed instance "saved" attribute in mongodb adapter #170

merged 1 commit into from over 1 year ago

3 participants

djrenren Larz Conwell Matthew Eernisse

Previously, instances were stored in the database with instance.saved = false. Even when they were obviously saved.

This commit fixes that issue. The problem was that we were setting

instance.saved = true

and then saving cleanInstance to the database.

Now it sets both instance.saved and cleanInstance.saved


We may not want to be saving it all (seeing as it's redundant). Should we just drop the "saved" attribute?

Larz Conwell

@mde is currently writing an ORM that's going to be used in Geddy so this may not be needed here anymore. But I'm not sure what he'd want to do here ATM.

Matthew Eernisse
mde commented

Yes, I'm pulling all the Geddy model stuff out into its own project, "Model": But the 'saved' attribute is what the ORM uses to know if the instance is a new one, or has been previously saved. (We might consider making it an underscore property: "_saved".)

Matthew Eernisse mde merged commit b68adda into from
Matthew Eernisse mde closed this
Matthew Eernisse
mde commented

In the meantime, at least the current Geddy model stuff will behave correctly. Saving something in the DB with "saved" = false is crazypants. :)


w00t my first accepted pull request! :D If you're looking for help with Model just lemme know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Aug 14, 2012
djrenren Fixed instance "saved" attribute in mongodb adapter 370f6eb
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 1 addition and 1 deletion. Show diff stats Hide diff stats

  1. 2  lib/model/adapters/mongo.js
2  lib/model/adapters/mongo.js
@@ -156,7 +156,7 @@ var Mongo = function (config) {
156 156
157 157
         // if we don't already have the to do item, save a new one
158 158
         else {
-          instance.saved = true;
+          cleanInstance.saved = instance.saved = true;
160 160
 , function(err, docs){
161 161
             return callback(err, instance);
162 162

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.