mongojson
v0.1.2
Published
MongoDB-compatible SDK for json-server — use MongoDB-like operations on top of a REST API
Maintainers
Readme
mongojson
MongoDB-compatible SDK for JSON Server. Use MongoDB-like operations on top of a REST API.
import { MongoClient } from "mongojson"
const uri = "mongodb://dbuser:[email protected]/mydb"
const client = new MongoClient(uri)
await client.connect()
const db = client.db()
const users = db.collection("users")
// Create
await users.insertOne({ name: "Alice", age: 30 })
// Read
const all = await users.find().toArray()
const alice = await users.findOne({ name: "Alice" })
// Update
await users.updateOne({ name: "Alice" }, { $set: { age: 31 } })
// Delete
await users.deleteOne({ name: "Alice" })
// Count
const total = await users.countDocuments()Installation
npm install mongojsonDocumentation
Full documentation including all operations, filter operators, update operators, error handling, and connection URI format is available at:
https://json.shahriyar.dev/docs/mongojson
License
MIT
