R
R
riddlr2018-09-22 20:08:54
MongoDB
riddlr, 2018-09-22 20:08:54

Why don't populations work with String instead of ObjectID?

Good evening everyone. why don't populations work with mongoose.Schema.Types.String? is it possible at all? code such
model Tweet.js

hashtags: [{ type: mongoose.Schema.Types.String, ref: 'Hashtag' }]

those. I store in the Tweets collection not the hashtag IDs, but the names (they are unique) everything works fine until the moment I do the populations.
"Cast to ObjectId failed for value \"one\" at path \"_id\" for model \"Hashtag\""

those. it still climbs into _id

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question