Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Collection not populated #45

Open
KevinBurton opened this issue Feb 29, 2016 · 0 comments
Open

Collection not populated #45

KevinBurton opened this issue Feb 29, 2016 · 0 comments

Comments

@KevinBurton
Copy link

I have the following code:

        var db = pmongo(mongodbConfig.url, mongodbConfig.options, mongodbConfig.collections);
        for(var i in mongodbConfig.collections) {
            db[mongodbConfig.collections[i]].remove();
        }
        return Promise.all(formDefinitions.map(function (formDefinitionItem) {
            var formDefinition = {};
            for(var formDefinitionProperty in formDefinitionItem) {
                if(formDefinitionItem.hasOwnProperty(formDefinitionProperty)) {
                    if(formDefinitionProperty != 'pages') {
                        formDefinition[formDefinitionProperty] = formDefinitionItem[formDefinitionProperty];
                    }
                }
            }
            return db[mongodbConfig.collections[0]].insert(formDefinition);
        })).then(function(allFormDefinitions) {

When I run this code no exceptions are thrown but the database (looking with the mongo shell) seems empty. Can you see anything obvious that I am doing wrong? The variable 'formDefinitions' is an array that I know is created correctly. The string mongodbConfig.collections is an array of strings and in this case so the string 'formDefinitions'. I have set a breakpoint at each return and the variable 'formDefinition' is correct. I am having a hard time seeing what is wrong that would cause the collection to be empty without error.

Thank you.

Kevin

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

No branches or pull requests

1 participant