Consider re-exporting some (all?) types from mongodb
DeadOce4n opened this issue Β· comments
Prerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the feature has not already been requested
π Feature Proposal
Re-export some (all?) types from mongodb
package.
Motivation
Currently there's no way of using most of the types included in this plugin's mongodb
dependency as they're not re-exported from the plugins type declaration files (I think only ObjectId
is being re-exported), to make use of those types it is necessary to install the mongodb
package as a dev dependency of the whole project.
I want to write a helper function to parse some queryString parameters and create a mongodb query object, currently the only way to make this type safe is to add mongodb as a dev dependency of the project and import the types from it, but this makes the project end up with two installations of the module (maybe even different!).
Example
import type { Filter } from '@fastify/mongodb' <--- This should be possible
// import type { Filter } from 'mongodb' <--- This shouln't be necessary
function filterParser(obj?: FilterSchema) {
const filter: Filter<Event> & Record<string, unknown> = {
active: true
}
Object.entries(obj ?? {}).forEach(([k, v]) => {
switch (k) {
case 'title':
case 'summary':
case 'description':
if (typeof v === 'string') {
filter[k] = { $regex: v, $options: 'i' }
}
break
...
Thanks for reporting!
Would you like to send a Pull Request to address this issue? Remember to add unit tests.