Skip to main content
The Deno 2 Release Candidate is here
Learn more

NOTICE: This project is currently experimental and may not work properly!

MongoData

A lightweight wrapper around MongoDB’s DataAPI.

Made for Deno Licence MIT Latest version Latest commit Status WIP

Key Features

  • Made for Deno
  • Pure Typescript
  • Lightweight
  • Zero dependencies

How To Use

import { DataAPI } from 'https://deno.land/x/mongodata/mod.ts';

const api = new DataAPI({
    appId: '<APP ID>',
    dataSource: '<CLUSTER NAME>',
    key: '<API KEY>',
});

const database = api.getDatabase('<DATABASE>');
const collection = database.getCollection('<COLLECTION>');

const doc = { name: 'Bob', age: 30 };

console.log(await collection.insertOne({ document: doc }));
// 0123456789abcdef01234567

console.log(await collection.findOne({ filter: { name: 'Bob' } }));
// { _id: "0123456789abcdef01234567", name: "Bob", age: 30 }

console.log(await collection.deleteOne({ filter: { name: 'Bob' } }));
// { deletedCount: 1 }

Known issues

  • [WIP] Currently you can not query BSON types (like ObjectIds)!

Contributing

Feel free to send merge requests!

You may also like…

  • deno_mongo - MongoDB database driver developed for Deno.

License

MIT


Homepage luke.id  ·  GitHub @lkwr  ·  Twitter @wlkrlk