erfanium / atlas_sdk Goto Github PK
View Code? Open in Web Editor NEWTypeSafe MongoDB Atlas Data API SDK for Deno, Deno Deploy and Node.js
Home Page: https://deno.land/x/atlas_sdk
License: MIT License
TypeSafe MongoDB Atlas Data API SDK for Deno, Deno Deploy and Node.js
Home Page: https://deno.land/x/atlas_sdk
License: MIT License
Would be nice to have this, since it's so common.
Source:
Lines 99 to 115 in b9ccb49
I ran a find on a large collection and get 1000 documents back, even though I have more documents than that. This is because calling cursor.documents
returns up to the batchSize in documents.
I think the API should instead return the plain cursor.
Is there any possibility top add the createIndex
command for collection?
I think gridfs support also can be implemented in this sdk.
import { MongoClient, UUID } from "https://deno.land/x/[email protected]/mod.ts";
const client = new MongoClient({
endpoint: "https://data.mongodb-api.com/app/YOUR_APP_ID/endpoint/data/v1",
dataSource: "YOUR_CLUSTER_NAME",
auth: {
apiKey: "YOUR_API_KEY",
},
});
await client.database("sampleDatabase").collection("sampleCollection").insertOne({
sampleUUID: new UUID(),
})
Error when trying to create document with uuid
error: Uncaught BSONTypeError: Unrecognized or invalid _bsontype: UUID
throw new BSONTypeError(
^
at serializeDocument (https://deno.land/x/[email protected]/src/extended_json.ts:318:15)
at serializeValue (https://deno.land/x/[email protected]/src/extended_json.ts:253:12)
at serializeDocument (https://deno.land/x/[email protected]/src/extended_json.ts:300:22)
at serializeValue (https://deno.land/x/[email protected]/src/extended_json.ts:253:12)
at serializeDocument (https://deno.land/x/[email protected]/src/extended_json.ts:300:22)
at serializeValue (https://deno.land/x/[email protected]/src/extended_json.ts:253:12)
at Module.stringify (https://deno.land/x/[email protected]/src/extended_json.ts:469:15)
at Collection.callApi (https://deno.land/x/[email protected]/client.ts:216:19)
at Collection.insertOne (https://deno.land/x/[email protected]/client.ts:81:17)
I basically copied the example on the docs and am getting the error in the title.
code:
import {
MongoClient,
ObjectId,
} from "https://deno.land/x/[email protected]/mod.ts";
import { config } from "https://deno.land/x/[email protected]/mod.ts";
const client = new MongoClient({
endpoint: `https://data.mongodb-api.com/app/${
config().DB_APP_ID
}/endpoint/data/v1`,
dataSource: config().DB_DATA_SOURCE,
auth: {
apiKey: config().DB_API_KEY,
},
});
interface Users {
_id: ObjectId;
name: string;
email: string;
}
const db = client.database(config().DB_NAME);
const users = db.collection<Users>("users");
// error is here
users.insertOne({ // <---
name: "John Doe",
email: "[email protected]",
});
error:
Argument of type '{ name: string; email: string; }' is not assignable to parameter of type 'Users'.
Property '_id' is missing in type '{ name: string; email: string; }' but required in type 'Users'.deno-ts(2345)
This was proposed by Github Copilot and seems to work:
users.insertOne({
name: "John Doe",
email: "[email protected]",
_id: new ObjectId(),
});
Works:
we need help to prepare this package to publish it to jsr
(Please ๐ if you want this)
Hi,
Since I have added strict validation to my model, some of my requests failed where why are encoded as application/ejson
but still works as application/ejson
it's looks like the bug is in mongoDB Data API, but the project is not opensource ...
to bypass the issue the request must be encoded as JSON, not EJSON.
Is that possible to force encoding to JSON ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.