vadimdemedes / mongorito

🍹 MongoDB ODM for Node.js apps based on Redux
1.38k stars 90 forks source link

Before save hook doesn't work #184

Closed DavidBernal closed 2 years ago

DavidBernal commented 7 years ago

I'm following the examples to abort save but doesn't work in node v8.0.0. I also test with —harmony param but nothing.

The example is in bottom: http://mongorito.com/guides/middleware/

Any help is welcome.

balazs-mocsai commented 7 years ago

Which package version are you on?

DavidBernal commented 7 years ago

Well, the problem is the documentation is outdated. With custom middleware works.

vadimdemedes commented 7 years ago

@DavidBernal you are right, documentation on the website is very old and I removed the link to it in the repository. I actually wrote mongorito-hooks module specifically for this purpose, but haven't released it yet.

DavidBernal commented 7 years ago

@vadimdemedes nice, I love mongorito but is a little hard with the current documentation

vadimdemedes commented 7 years ago

@DavidBernal Could you point out what's confusing so that's everyone can improve it? Talking about the current readme, where all docs reside.

DavidBernal commented 7 years ago

@vadimdemedes For example, I don't know how to create index for a collection. I see createIndex function in src, but is it not in documentation. Me neither I don't know how to do a search in collection before create new document.

vadimdemedes commented 7 years ago

Re indexes, you are right, it's not documented yet. Here's how to use it until then: https://github.com/vadimdemedes/mongorito/blob/master/test/indexes.js#L12.

As for the search, it's no longer supported in the core, but supposed to be implemented in a 3rd-party plugin.