glutinum-org / Glutinum

MIT License
30 stars 3 forks source link

Question: MongoDB Bindings #9

Open AngelMunoz opened 2 years ago

AngelMunoz commented 2 years ago

Inspired by the Glutinum bindings for Express I decided allow a small mongo commands DSL library I made a few months back to run on Fable I added a sample here thinking that there might be node projects that use mongo and can't simply be migrated to .NET/Fable just due the database

the missing glue (bad pun I know) here is the mongodb driver bindings as you can see in sample.js you don't actually need to bind the whole library just a MongoClient with a few extra types might be needed

How do binding requests work and what do I actually need to do in case this looks do'able?

MangelMaxime commented 2 years ago

the missing glue (bad pun I know)

Then I am the culpit of the bad pun as the project name come from it 🤣 https://github.com/glutinum-org/Glutinum#why-this-name

The goal of Glutinum is to explore how we can improves the bindings and provides "quality" / tested bindings for JavaScript libraries.

Binding only the MongoClient doesn't exactly fit into this goal but it is true that we can't directly have a binding 100% done. For example, even if Express has 424 not everything is tested yet.

With that being said, I think the most important point of Glutinum is to have tests written for the "supported" APIs. The reason being that it will help us make it safer to improve the bindings and also detect breaking changes, API regression.

If you are ok to write some of the bindings and tests that goes with it.

Here is how you can add a new glue to the project:

If my script works has expected 😇

  1. npm install
  2. Invoke the build.js script with the init arguments

    https://github.com/glutinum-org/Glutinum#how-to-use-this-repository

    For example, build.js init

  3. Follow the instructions
  4. After adding the glue to the projects list in the 'build.js' file, you should be able to run build.js test --project projectName to run the tests against that project.

In order, to have a Mongo instance to run the tests against, we can take inspiration from how they do it in mongo repo. Manually starting a server instance.

https://github.com/mongodb/node-mongodb-native/blob/4.0/CONTRIBUTING.md#running-the-tests

In the future, I am planning to have the glues separated in different repo so we can have docker file or custom CI available for them but as everything is still Work In Progress right now, it is easier to have a mono repo.