# JDBC MONGO and objectId type

**URL:** <https://discuss.elastic.co/t/jdbc-mongo-and-objectid-type/225760>\
**Category:** Logstash\
**Created:** [March 30, 2020, 10:46pm UTC](https://discuss.elastic.co/t/jdbc-mongo-and-objectid-type/225760 "2020-03-30T22:46:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![7cinquante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/7cinquante/32/65338_2.png) [@7cinquante](https://discuss.elastic.co/u/7cinquante)\
**Post date:** [March 30, 2020, 10:46pm UTC](https://discuss.elastic.co/t/jdbc-mongo-and-objectid-type/225760/1 "2020-03-30T22:46:59Z")

</div>

For people who are looking for convert objectId type from mongo to string in logstash

```auto
statement => "db.getCollection('YOUR_COLLECTION').aggregate([
    			 		{ $project: {
    							'_id': {$toString: '$_id'},
    							'FIELD_1':1,
    							'FIELD_2':1,
    							'FIELD_3':1 .......
    						}
    					}
    					]);"

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 27, 2020, 10:47pm UTC](https://discuss.elastic.co/t/jdbc-mongo-and-objectid-type/225760/2 "2020-04-27T22:47:09Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
