Skip to content
This repository

Fixed instance "saved" attribute in mongodb adapter #170

Merged
merged 1 commit into from over 1 year ago

3 participants

djrenren Larz Conwell Matthew Eernisse
djrenren

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

djrenren

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
Owner
mde commented August 14, 2012

Yes, I'm pulling all the Geddy model stuff out into its own project, "Model": https://github.com/mde/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 August 14, 2012
Matthew Eernisse mde closed this August 14, 2012
Matthew Eernisse
Owner
mde commented August 14, 2012

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

djrenren

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 {
159  
-          instance.saved = true;
  159
+          cleanInstance.saved = instance.saved = true;
160 160
           self.collection.save(cleanInstance, function(err, docs){
161 161
             return callback(err, instance);
162 162
           });
Commit_comment_tip

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.