Comments (4)
It looks like the incoming ObjectId is invalid. Can you confirm that the ID is correct?
And about the _id field, you can use the ObjectId constructor to create:
import {ObjectId} from "https://deno.land/x/[email protected]/mod.ts";
// ...
const doc = await collection.findOne ({_ id: ObjectId ("xxxxxxx")});
from mongo.
Yes, the ObjectId is invalid.
I want to know how can we handle the error if invalid ObjectId is used. I don't want such errors to crash the server.
from mongo.
ObjectId's correctness verification is placed in the TS side. If you use the ObjecId constructor, you can catch the error. If you do it on the Rust side, you have to deal with tedious error mapping
from mongo.
Thanks a lot for the information. I will keep these things in mind. :)
from mongo.
Related Issues (20)
- Implment `findOneAnd[Replace|Update|Delete]` methods
- Error when insertOne HOT 2
- Client closing leads to BadResource / Interrupted
- support readPreference/readPreferenceTags ? HOT 5
- Uncaught BSONError: cyclic dependency detected HOT 1
- Should we deprecate this module since importing with `npm:mongodb` is working well with Deno? HOT 17
- Connection failed: Failed to decode base64 HOT 2
- `$push`ing to an array causes type errors.
- Error when deleting empty file in GridFS. HOT 2
- MongoDB not working search for an object by its ObjectId HOT 1
- Type error when using unset in update methods
- Update to reflect [email protected] HOT 1
- Update toβ [email protected] βTo implement "privateKey" and "certChain" in "Deno. ConnectTlsOptions". HOT 1
- using new ObjectId() breaks fresh island HOT 5
- feat: db.runCommand HOT 1
- Connection fail HOT 2
- Make connection errors catchable
- Is this module working with AWS DocumentDB? HOT 1
- Avoid console.error (throw if needed) HOT 1
- no $option in FilterOperators for $regex?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mongo.