{"id":45474,"library":"mongojson","title":"mongojson","description":"MongoDB-compatible SDK for json-server (v0.1.2). Provides a MongoDB-like query interface (find, insertOne, updateOne, deleteOne, countDocuments) on top of a REST API. Designed to work with JSON Server instances, allowing developers to use familiar MongoDB operations without a full MongoDB backend. Includes TypeScript types. Released as a single version; no major updates yet. Differentiator: bridges MongoDB syntax with REST endpoints for quick prototyping.","status":"active","version":"0.1.2","language":"javascript","source_language":"en","source_url":"https://github.com/shahriyardx/json-server","tags":["javascript","json-server","mongodb","sdk","rest","typescript"],"install":[{"cmd":"npm install mongojson","lang":"bash","label":"npm"},{"cmd":"yarn add mongojson","lang":"bash","label":"yarn"},{"cmd":"pnpm add mongojson","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM-only package; CommonJS require will fail.","wrong":"const MongoClient = require('mongojson')","symbol":"MongoClient","correct":"import { MongoClient } from 'mongojson'"},{"note":"Type export for TypeScript users; not commonly used directly.","wrong":null,"symbol":"Db","correct":"import { Db } from 'mongojson'"},{"note":"Type export for TypeScript users; not commonly used directly.","symbol":"Collection","correct":"import { Collection } from 'mongojson'"}],"quickstart":{"code":"import { MongoClient } from 'mongojson';\n\nconst uri = 'mongodb://dbuser:dbpass@yourusername.json.shahriyar.dev/mydb';\nconst client = new MongoClient(uri);\nawait client.connect();\n\nconst db = client.db();\nconst users = db.collection('users');\n\n// Create\nawait users.insertOne({ name: 'Alice', age: 30 });\n\n// Read\nconst all = await users.find().toArray();\nconst alice = await users.findOne({ name: 'Alice' });\n\n// Update\nawait users.updateOne({ name: 'Alice' }, { $set: { age: 31 } });\n\n// Delete\nawait users.deleteOne({ name: 'Alice' });\n\n// Count\nconst total = await users.countDocuments();\n\nconsole.log('Success!');","lang":"typescript","description":"Demonstrates full CRUD and count using MongoDB-like syntax with mongojson against a JSON Server backend."},"warnings":[{"fix":"Ensure your backend is a JSON Server instance supporting mongojson operations.","message":"The MongoDB-like operations are only supported on JSON Server instances that implement the expected REST endpoints. Not compatible with actual MongoDB databases.","severity":"gotcha","affected_versions":">=0.0.0"},{"fix":"Use the correct URI format as shown in the documentation.","message":"Connection URI must match the JSON Server format 'mongodb://user:pass@host/db'. Using a standard MongoDB URI will fail.","severity":"gotcha","affected_versions":">=0.0.0"}],"env_vars":null,"search_vec":"'allow':36 'api':28 'backend':47 'bridg':61 'compat':4 'countdocu':22 'deleteon':21 'design':29 'develop':37 'differenti':60 'endpoint':66 'familiar':40 'find':18 'full':45 'includ':48 'inserton':19 'instanc':35 'interfac':17 'javascript':70 'json':8,33,72 'json-serv':7,71 'like':15 'major':57 'mongodb':3,14,41,46,62,74 'mongodb-compat':2 'mongodb-lik':13 'mongojson':1 'oper':42 'prototyp':69 'provid':11 'queri':16 'quick':68 'releas':51 'rest':27,65,76 'sdk':5,75 'server':9,34,73 'singl':54 'syntax':63 'top':24 'type':50 'typescript':49,77 'updat':58 'updateon':20 'use':39 'v0.1.2':10 'version':55 'without':43 'work':31 'yet':59","created_at":"2026-06-07T12:55:11.302424+00:00","updated_at":"2026-06-07T12:55:11.302424+00:00","problems":[{"fix":"Run 'npm install mongojson' and use ESM import syntax.","cause":"Package not installed or imported incorrectly in CommonJS.","error":"Error: Cannot find module 'mongojson'"},{"fix":"Ensure you use `new MongoClient(uri)` and then call `await client.connect()`.","cause":"Attempting to call connect before creating a client or using wrong import.","error":"TypeError: client.connect is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/shahriyardx/json-server#readme","github":"https://github.com/shahriyardx/json-server","docs":null,"changelog":null,"pypi":null,"npm":"mongojson","openapi_spec":null,"status_page":null,"smithery":null,"categories":["database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}