Comments (9)
have you tried defining a cast for that particular property?
casts: { account: ObjectID }
above your model you will need to define ObjectID. You should be able to do the following.
var ObjectID = require('mongodb').ObjectID
if you want the casting to be automatic you can just add an underscore to the name, and mongoose will handle the rest.
from mongoose.
I did try a cast how you suggested, but that also didn't work, and I use an underscore at the beginning of the field name. Keep in mind, the property is getting set on the object as I can see by inspecting the object before and after save, however when I view the object in the database, or load the object back up, that property is unset.
from mongoose.
and that particular property is defined in your properties: [] ?
for sanity checking you can inspect doc.__doc to see if the property is actually in the internal doc that gets saved down.
from mongoose.
Yes it is present in my properties array. It is present in the __doc. It is also marked as dirty. Every other field saves properly. If I inspect after I save, it is also still there. However, if I load it back up, or inspect it with MongoHub, it is empty.
from mongoose.
any other information you can provide would be great. Like what version of mongodb your connecting too. I have not seen this issue, I'll try and reproduce later.
from mongoose.
I'm using edge version of MongoDB.
from mongoose.
do you know what version of mongodb-native your using? It should be locked in at v0.7.9.
check out my comment on http://github.com/LearnBoost/mongoose/issues#issue/47 for reasons why.
from mongoose.
Ug. MongoHub is the culprit. It doesn't display ObjectID's other than _id apparently. I had thought I had tested without MongoHub but I must not have. Sorry to waste your time on this.
from mongoose.
resolved
from mongoose.
Related Issues (20)
- Recursive nested discriminators
- Add overwriteDiscriminatorKey to API docs for `findOneAndUpdate()`, `updateOne()`; and `findOneAndUpdate()` guide HOT 2
- timestamps query option doesn't work in 6.x+ HOT 3
- Dynamic Object ID reference for a subdocument inside an array
- wrongly update timestamps on updateOne HOT 18
- Inconsistent behaviour for .create/.save vs updateOne/findOneAndUpdate for null values HOT 6
- TypeScript broken on latest release HOT 2
- Why ObjectId type is such extremly complex? HOT 6
- $in not working HOT 1
- Hook into bulkWrite
- asPromise should be mentioned in error handling documentation
- Strange behavior with Transactions and document updates HOT 2
- Cannot patch a sub-document with destructuring HOT 5
- how to get more info no this error?
- TypeError: mongoose__WEBPACK_IMPORTED_MODULE_0___default(...).connect is not a function HOT 9
- 8.1 middleware pre hook typescript types broken? HOT 2
- Can't seem to type my functions correctly (using discriminator models) HOT 3
- 'Require_id<FlattenMaps<T>>' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint 'AbstractEntity'. HOT 1
- [REG 8.0.3->8.0.4/8.1.0] updateOne/updateMany can no longer accept runValidators/new HOT 3
- Type definition for Connection.prototype.createCollections() not in connections.d.ts
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 mongoose.