mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 08:19:07 +00:00
Stringify ObjectID
This commit is contained in:
parent
8500403297
commit
4a7cae4ac0
@ -8,7 +8,17 @@
|
||||
const mongoose = require('mongoose');
|
||||
const Mongoose = mongoose.Mongoose;
|
||||
|
||||
/**
|
||||
* Convert MongoDB ID to the stringify version as GraphQL throws an error if not.
|
||||
*
|
||||
* Refer to: https://github.com/graphql/graphql-js/commit/3521e1429eec7eabeee4da65c93306b51308727b#diff-87c5e74dd1f7d923143e0eee611f598eR183
|
||||
*/
|
||||
mongoose.Types.ObjectId.prototype.valueOf = function () {
|
||||
return this.toString();
|
||||
};
|
||||
|
||||
module.exports = (mongoose = new Mongoose()) => {
|
||||
|
||||
const Decimal = require('mongoose-float').loadType(mongoose, 2);
|
||||
const Float = require('mongoose-float').loadType(mongoose, 20);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user