@useful/mongo

import { connect, disconnect, getDatabase, getCollection, generateId } from "@userful/mongo";

Usage no npm install needed!

<script type="module">
  import usefulMongo from 'https://cdn.skypack.dev/@useful/mongo';
</script>

README

@useful/mongo

Example usage

import {
  connect,
  disconnect,
  getDatabase,
  getCollection,
  generateId
} from "@userful/mongo";

(async function() {
  await connect();
  const Users = await getCollection("users");
  const user = await Users.findOne({});
  await Users.insert({
    _id: generateId()
    /* Other fields */
  });
  await disconnect();
})();