{"action":"reopened","issue":{"url":"https://api.github.com/repos/Automattic/mongoose/issues/7274","repository_url":"https://api.github.com/repos/Automattic/mongoose","labels_url":"https://api.github.com/repos/Automattic/mongoose/issues/7274/labels{/name}","comments_url":"https://api.github.com/repos/Automattic/mongoose/issues/7274/comments","events_url":"https://api.github.com/repos/Automattic/mongoose/issues/7274/events","html_url":"https://github.com/Automattic/mongoose/issues/7274","id":383586052,"node_id":"MDU6SXNzdWUzODM1ODYwNTI=","number":7274,"title":"document.toObject does not convert Mongoose Maps to POJOs","user":{"login":"stjosh","id":7030415,"node_id":"MDQ6VXNlcjcwMzA0MTU=","avatar_url":"https://avatars3.githubusercontent.com/u/7030415?v=4","gravatar_id":"","url":"https://api.github.com/users/stjosh","html_url":"https://github.com/stjosh","followers_url":"https://api.github.com/users/stjosh/followers","following_url":"https://api.github.com/users/stjosh/following{/other_user}","gists_url":"https://api.github.com/users/stjosh/gists{/gist_id}","starred_url":"https://api.github.com/users/stjosh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stjosh/subscriptions","organizations_url":"https://api.github.com/users/stjosh/orgs","repos_url":"https://api.github.com/users/stjosh/repos","events_url":"https://api.github.com/users/stjosh/events{/privacy}","received_events_url":"https://api.github.com/users/stjosh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/Automattic/mongoose/milestones/270","html_url":"https://github.com/Automattic/mongoose/milestone/270","labels_url":"https://api.github.com/repos/Automattic/mongoose/milestones/270/labels","id":3845135,"node_id":"MDk6TWlsZXN0b25lMzg0NTEzNQ==","number":270,"title":"5.3.15","description":"","creator":{"login":"vkarpov15","id":1620265,"node_id":"MDQ6VXNlcjE2MjAyNjU=","avatar_url":"https://avatars2.githubusercontent.com/u/1620265?v=4","gravatar_id":"","url":"https://api.github.com/users/vkarpov15","html_url":"https://github.com/vkarpov15","followers_url":"https://api.github.com/users/vkarpov15/followers","following_url":"https://api.github.com/users/vkarpov15/following{/other_user}","gists_url":"https://api.github.com/users/vkarpov15/gists{/gist_id}","starred_url":"https://api.github.com/users/vkarpov15/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkarpov15/subscriptions","organizations_url":"https://api.github.com/users/vkarpov15/orgs","repos_url":"https://api.github.com/users/vkarpov15/repos","events_url":"https://api.github.com/users/vkarpov15/events{/privacy}","received_events_url":"https://api.github.com/users/vkarpov15/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":7,"state":"closed","created_at":"2018-11-24T18:49:28Z","updated_at":"2018-12-13T22:02:55Z","due_on":"2018-12-03T08:00:00Z","closed_at":"2018-12-05T22:25:04Z"},"comments":4,"created_at":"2018-11-22T15:41:52Z","updated_at":"2018-12-13T22:02:55Z","closed_at":null,"author_association":"NONE","body":" I think there's still a bug similar to  #6478: \r\n\r\n**What is the current behavior?**\r\nWhen converting a Mongoose document to an object via `toObject`, a Map still remains a Map. As from that point on I actually expect to be working with a POJO, this is problematic, especially since I'm converting it to JSON a bit later and will end up with an empty Object instead of a POJO representing my map.\r\n\r\nThe following, slightly modified script from #6486 should demonstrate the issue:\r\n```javascript\r\n#!/usr/bin/env node\r\n'use strict';\r\n\r\nconst mongoose = require('mongoose');\r\nmongoose.connect('mongodb://localhost/test');\r\nconst conn = mongoose.connection;\r\nconst Schema = mongoose.Schema;\r\nconst Map = global.Map;\r\n\r\nconst schema = new Schema({\r\n  test: {\r\n    type: Map,\r\n    of: String,\r\n    default: new Map()\r\n  }\r\n});\r\n\r\nconst Test = mongoose.model('test', schema);\r\n\r\nconst mapTest = new Test({});\r\n\r\nmapTest.test.set('key1', 'value1');\r\n\r\nasync function run() {\r\n  await conn.dropDatabase();\r\n  await mapTest.save();\r\n  let found = await Test.findOne();\r\n  let pojo = found.toObject();\r\n  console.log(JSON.stringify(pojo));\r\n  return conn.close();\r\n}\r\n\r\nrun();\r\n```\r\n\r\n**What is the expected behavior?**\r\nI'd expect `toObject` to map a MongooseMap to a POJO as well.\r\n\r\n**Please mention your node.js, mongoose and MongoDB version.**\r\nNode: v11.1.0\r\nMongoDB: 3.6.5"}}
{"actor":{"display_login":"vkarpov15"}}