The deno-mongo guide page on GitHub is no longer functional. You can find the page here: 'https://github.com/manyuanrong/deno_mongo'
I am struggling to understand how to use the plugin and get it up and running.
Following the example in the "Readme.md" file, I encounter this error:
import { MongoClient } from 'https://deno.land/x/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0f62606168604f793f213e3e213e">[email protected]</a>/mod.ts'
const client = new MongoClient()
client.connectWithUri('mongodb://localhost:27017') // encountering an error at this point
const db = client.database('test')
const users = db.collection('users')
const insertId = await users.insertOne({
username: 'user1',
password: 'pass1'
})
This leads to the following errors:
Error: The plugin must be initialized before use
at dispatch (util.ts:72:11)
at MongoClient.connectWithUri (client.ts:101:18)
at ...
An INFO message follows (likely from the denomongo module)
INFO load deno plugin "deno_mongo" from local `/home/${localfiles}/.deno_plugins/deno_mongo_5c404deeadd1e8a86535eb51aca17e4d.so`
I have tried various approaches to solve this issue including:
import { init, MongoClient } from 'https://deno.land/x/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d8b5b7b6bfb798aee8f6e9e9f6e9">[email protected]</a>/mod.ts'
init(${pathname}) // In my actual code, I provided the real path where '.deno_plugins/deno_mongo~~~.so' exists. (even though I'm unsure of what this file is for or when it is created)
const client = new MongoClient()
client.connectWithUri('mongodb://localhost:27017')
const db = client.database('test')
const users = db.collection('users')
const insertId = await users.insertOne({
username: 'user1',
password: 'pass1'
})
However, this only resulted in another INFO message:
INFO downloading deno plugin "deno_mongo" from "${pathname}/libdeno_mongo.so"
This approach did not work. How should I go about resolving this?