Be advised: this project is currently at Major version zero. Per the semantic versioning spec: "Major version zero (0.y.z) is for initial development. Anything may change at any time. The public API should not be considered stable."
Javascript library to embed an arbitrary number of mongoDb dbs/collections within a single cosmosDb collection
Microsoft bills for increments of RU's (capacity/throughput) across 2 dimensions:
Collections
pricing: increments of 100 RU/second, with a minimum of 400 RU/second
comments: Lame... I want to pay for usage; not collections. I should be able to use as many collections as my design dictates
Databases
pricing: increments of 10K RU/second, with a minimum of 50K RU/second
comments: Lame... I want to pay for usage; not dbs. I should be able to use as many dbs as my design dictates
embed an arbitrary number of mongoDb dbs/collections within a single cosmosDb collection.
- add
_db
&_collection
discriminators on all documents - observe discriminators for all api operations
npm install --save mongo-in-cosmos
yarn add mongo-in-cosmos
All implemented methods, are identical to the native mongoDb driver collection API.
db
db.collection
db.collection.find
db.collection.findOne
db.collection.insertOne
db.collection.updateOne
const MongoClient = require('mongodb').MongoClient
const mongoInCosmos = require('mongo-in-cosmos')
const cosmosConnect = await MongoClient.connect(cfg.mongoDbConnectionString)
// get cosmosDb collection using native mongo driver
const cosmosCollection = cosmosConnect
.db('my-cosmos-db')
.collection('my-cosmos-collection')
// get embedded collection using mongo-in-cosmos
const embeddedCollection = mongoInCosmos(cosmosCollection)
.db('my-embedded-db')
.collection('my-embedded-collection')
// use like native mongo driver collection (for implemented methods)... :)
await embeddedCollection.find({})
releases are versioned according to and tagged; see CHANGELOG.md for release notes
see CONTRIBUTING.md