Comments (9)
based on what you have above and especially given your solution, wouldn't it be more correct to say your findByPermalink(permalink).first is the suspect? a find should not return isNew = true. and if i update the model.test.js to add isNew assertion test cases after a find, they all pass (http://github.com/cginzel/mongoose/blob/faabdc1a55f9bb9716f750bb3be72187ce61d193/tests/integration/model.test.js) where is the code for findByPermalink(permalink).first?
from mongoose.
I've just added findByPermalink in the static methods of the model.
mongoose.model('Story',{ collection : 'stories', 'static' : { findByUserid : function(userid) { return this.find({'user.id':userid,'deleted':null}); }, findByUsername : function(username) { return this.find({'user.username':username,'deleted':null}); }, findByPermalink : function(permalink) { return this.find({'permalink':permalink,'deleted':null}); },
from mongoose.
do the test cases in my link above pass when you run it in your environment?
from mongoose.
All tests are ok.
Weird. I've moved on doing soft delete (with a delete flag) so I won't have to delete anything from mongodb. Let's see how it goes.
from mongoose.
Thanks for your support btw!
from mongoose.
are you sure the your query actually returns rows? this.find({'permalink':permalink,'deleted':null}); i was convinced at one point the delete did not work too, but i finally figured out that it was my query that was not right.
from mongoose.
I thought exactly what you did there. This works instead:
R.remove({'permalink':permalink,'deleted':null}, function() { // where R is the model name of r
//your callback functionality here
})
from mongoose.
Just to add, there are two remove() functions inside Mongoose. One is the one you pointed above, the other one is a "class" one that takes a where query and the callback function. The second one works perfectly.
from mongoose.
resolved
from mongoose.
Related Issues (20)
- Turn off "don't cast update pipelines by default" in favor of a more secure approach HOT 2
- Add TypeScript interface for the new PipelineStage - Vector Search HOT 1
- Add `pre` and `post` function types on Query class
- Nested populate with nested paths and subdocuments is not working fine HOT 6
- Best method to set Query and Lean defaults HOT 4
- Issue with 2dsphere indexes in nested schemas vs subdocuments HOT 2
- (Typescript) toObject on populated documents loses the structure
- Recompiling schema does not reapply discriminators HOT 1
- Using default value on sub documents does not work as expected HOT 3
- Recursion check in toObject breaks mongoose-intl plugin
- Cannot define discriminator options on a Schema HOT 1
- Model.createSearchIndex() create SIGTERM on DuplicateIndex
- Populate doesn't work - nested path + wildcard + 2 references on a same model
- How to catch MongoNetworkError: connect ECONNREFUSED in Node when using mongoose.createConnection() HOT 2
- Pre and Post (middleware) hooks issue
- getters array in virtualtype for "id" virtual is not deduped HOT 1
- FilterQuery Typing fails for generic type HOT 4
- Change tracking is getting lost on transaction retry HOT 1
- Types break in semver patch change HOT 4
- "$inc" operator not working HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongoose.