Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cyclic dependency error with mongodb

        var newsfeed = db.collection('newsfeed');
        newsfeed.findAndModify({
            _id: mongodb.ObjectId(newsfeedId)
        }, {
            new: true
        }, {
            $set: newsfeed
        }, function(err, result) {
            if (err) {
                return reject(err);
            } else {
                return resolve(result.value);
            }
        });

I get a cyclic dependency error when i run this query on mongodb, ive read through other solutions presented in stackoverflow but cant seem to fix this error .. this is the error message i see enter image description here

like image 632
Avindu Hewa Avatar asked Dec 13 '16 12:12

Avindu Hewa


People also ask

How would you fix a cyclic dependency?

A cyclic dependency is an indication of a design or modeling problem in your software. Although you can construct your object graph by using property injection, you will ignore the root cause and add another problem: property injection causes Temporal Coupling. Instead, the solution is to look at the design closely.

How do you identify cyclic dependency?

Analyze cyclic dependenciesFrom the main menu, select Code | Analyze Code | Cyclic Dependencies. In the Specify Cyclic Dependency Analysis Scope dialog, select the scope of files that you want to analyze. Select the Include test sources option if you want to analyze your test code together with the production code.

How do I fix circular dependency in react?

This circular relationship caused a problem and webpack could not resolve the dependencies correctly. Our solution was to upgrade our modules to use ES6 import/exports. This enabled us to reuse the react components and avoid circular dependencies while moving us closer to ES standards.


1 Answers

You are setting the newsfeed object back to newsfeed collection. Try to include the field which needs to be updated instead of whole object.

like image 187
s7vr Avatar answered Oct 21 '22 07:10

s7vr