Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should we deprecate this module since importing with npm:mongodb is working well with Deno? #380

Open
erfanium opened this issue Sep 24, 2022 · 23 comments

Comments

@erfanium
Copy link
Member

erfanium commented Sep 24, 2022

npm:mongodb pros:

  • almost all driver features are working for me
  • maintained by mongodb inc
  • universal api style for both node and deno

cons:

  • requried --unstable flag it's not compatible with Deno Deploy for now
  • uses node's Buffer instead of Uint8Array
  • uses node's Stream instead of async iterator and WebStream
  • is not as fast as x/mongo because uses node compat layer
@erfanium erfanium pinned this issue Sep 24, 2022
@lucsoft
Copy link
Collaborator

lucsoft commented Sep 24, 2022

I would love a hybrid version were we would use npm as a default but also webify the interfaces nodejs brings

@erfanium
Copy link
Member Author

We can publish a new module on npm like mongodb-webified. It can benfites both worlds

@steverandy

This comment was marked as off-topic.

@erfanium

This comment was marked as off-topic.

@steverandy

This comment was marked as off-topic.

@erfanium
Copy link
Member Author

@steverandy please report it on fresh github repo. Thanks
Not related to this issue

@lucsoft
Copy link
Collaborator

lucsoft commented Sep 26, 2022

We can publish a new module on npm like mongodb-webified. It can benfites both worlds

i prefer that it stays here. Else people could be thinking that it's not really made for Deno.

@josephrocca
Copy link

josephrocca commented Oct 28, 2022

I just tried the npm: version (v4.11.0 with Deno v1.27.0) and it for some reason it hung 90% of the time and never connected (no error thrown).

const client = new MongoClient(`mongodb://${user}:${pass}@${ip}:${port}/${dbName}`);
await client.connect();
db = client.db(dbName);

Strange that it works sometimes. Seems premature to deprecate this unless I'm making some sort of weird mistake there, but that seems like a good idea in the long run - if only to have consistency of the API between Node and Deno.

Edit: Just tested with npm:[email protected] and it seems to work fine now.

@vorticalbox
Copy link

You can follow the issues with mongoose/mongodb with deno here

denoland/deno#15824

@jtoppine
Copy link

Well, since this issue is in question format, might as well give my 2 cents.

It would be sad to see "native" deno mongo driver go, or fall into disrepair. Deno driver has the potential to be cleaner, prettier and faster, and the npm compatibility layer is big, complex and slow-ish to load.

It seems to also be true that there is a lack of maintainers to keep working on the Deno driver. And that it needs nontrivial amount of work to be good enough for widespread production use. Since the userbase is small for now, and the node driver is usable already as-is, it may be unrewarding to work on the Deno driver.

Maybe the best solution for now would be to put a big banner on the readme, with:

  • "call for maintainers"
  • a note about the deno driver being alpha/beta quality, maybe detailing some of the most important missing features (automatic reconnect etc)
  • a note to suggest regular users may want to use the NPM driver (for now)

This way regular users would not be discouraged from using Deno because of frustrating problems with unstable drivers. And there would be hope for the project to gain maintainers in the future, or even some "official" support from Mongo, eventually improving the driver beyond the NPM driver :)

@ThePotatoChronicler
Copy link

@erfanium The compatibility is not quite there yet: denoland/deno#16633

@denizdogan
Copy link

@erfanium The compatibility is not quite there yet: denoland/deno#16633

This has supposedly been fixed in Deno 1.37!

@fro-profesional
Copy link

fro-profesional commented Sep 25, 2023

I jus tried on local an deploy and seems to be working with MongoDB Atlas serverless deno v1.37

import { MongoClient } from "npm:mongodb"
import { ulid } from "https://deno.land/[email protected]/ulid/mod.ts";

const client = new MongoClient("<url>")

client.connect();

Deno.serve(async () => {

  const data = await client.db("deno").collection("deno").insertOne({
    name: ulid()
  })

  return new Response(JSON.stringify({
    data
  }), {
    headers: { "Content-Type": "application/json" },
  })
})

@alexbevi
Copy link

alexbevi commented Oct 6, 2023

Hey all, just wanted to chime in here as I'm the Product Manager at MongoDB for the Node.js driver, as well as the reporter of denoland/deno#16633 (which was addressed directly in the driver, as well as in the runtime via denoland/deno#20314).

Ultimately the goal is to have an ideal, runtime agnostic driver that the community can use so if there are still issues with using the driver via Deno I'd love to hear them :)

@lucsoft
Copy link
Collaborator

lucsoft commented Oct 6, 2023

@alexbevi Would be cool if the Node.js driver would be Webified and uses modern standard. Same as what happened with BSON which is almost Node.js free which is awesome. My dream would be that the deno/nodejs driver could be the same code and only need to polyfill the Direct Sockets API :D (and maybe in the future not even that)

@alexbevi
Copy link

alexbevi commented Oct 6, 2023

Thanks for the feedback @lucsoft. We're currently evaluating the driver against Deno to see if there's anything that outright doesn't work (feel free to share if you're aware of features that don't work)

@erfanium
Copy link
Member Author

erfanium commented Oct 6, 2023

@alexbevi Thanks for reaching out to us! As far as I know, MongoDB's official driver for Node.js only ships with CJS modules. So, you'd need to use Deno's npm compatibility layer to use the official driver.

I'd love to see MongoDB's official driver shipped as a Deno-native package in the deno.land/x registry, just like this module. with no dependency to std/node

@denodrivers denodrivers deleted a comment from DanCuatro Oct 9, 2023
@JWhist
Copy link

JWhist commented Sep 24, 2024

Chiming in with an update that the recommended Atlas-SDK leans on the Data API which is now deprecated and has (I think) one year of life left. I couldn't find any reasonably well working deno compatible drivers that would cooperate with Netlify Edge Functions (Deno Deploy), and they fail to bundle the npm:mongo driver, although it does work locally when testing with the Netlify CLI.

@lucsoft
Copy link
Collaborator

lucsoft commented Sep 24, 2024

We need to start to differentiate. if you use Atlas use the Atlas SDK. Atlas is not MongoDB, its Atlas.

@JWhist
Copy link

JWhist commented Sep 30, 2024

FWIW i was able to get the regular mongo driver working on Netlify edge functions by using an older version, without the dependency on the newer web-bson package. Version 0.31.1 worked for me, however the newer versions had a problem imported that dependency.

@softbeehive
Copy link

We need to start to differentiate. if you use Atlas use the Atlas SDK. Atlas is not MongoDB, its Atlas.

Mongo Atlas deprecated Data API
https://www.mongodb.com/docs/atlas/app-services/deprecation/#std-label-app-services-deprecation

I guess by using Atlas for production you risk being forced into costly migration when they shut it down completely

@dwstevens
Copy link

Also adding my 0.02, FWIW, I think deno has an opportunity to move into an Elixir like space for Typescript, and has already started down that road with std lib / jsr. I’d like to see first class std lib type support for the major DBs.

@jonseppanen
Copy link

It seems like the deno imported npm library for mongo does not support unix domain sockets - is this expected behaviour or an oversight?
Where is the correct place to raise such an issue? It seems like it would be more on the deno/npm side but it kinda crosses boundaries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests