{"id":1530,"date":"2020-07-30T22:17:30","date_gmt":"2020-07-31T05:17:30","guid":{"rendered":"https:\/\/www.couchbase.com\/blog\/migrating-data-from-mongodb-to-couchbase\/"},"modified":"2020-07-30T22:17:30","modified_gmt":"2020-07-31T05:17:30","slug":"migrating-data-from-mongodb-to-couchbase","status":"publish","type":"post","link":"https:\/\/www.couchbase.com\/blog\/migrating-data-from-mongodb-to-couchbase\/","title":{"rendered":"Migrating Data from MongoDB to Couchbase"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Prologue<\/h2>\n\n\n\n<p>This article guides you through a one-time MongoDB migration to Couchbase. You will learn how to export from the MongoDB data structure, import to Couchbase, and do some basic transformation on those documents.<\/p>\n\n\n\n<p>All code from this blog is available in the following Git repository: <a href=\"https:\/\/github.com\/dugbonsai\/mongodb-to-couchbase\">mongodb-to-couchbase<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>This article uses the sample mflix dataset that has been loaded to a MongoDB cluster. I am using MongoDB Atlas but the information in this article applies to non-Atlas installs of MongoDB also. If you need to load the sample dataset to MongoDB refer to the <a href=\"https:\/\/docs.atlas.mongodb.com\/sample-data\/load-sample-data\/#load-sample-data\">instructions here<\/a>.<\/p>\n\n\n\n<p><a href=\"https:\/\/www.mongodb.com\/products\/compass\">MongoDB Compass<\/a> is used to export the dataset and this article assumes it is already configured to connect to the MongoDB cluster where the sample mflix dataset resides.<\/p>\n\n\n\n<p>You will also need a Couchbase Server Enterprise Edition (EE) 6.5 cluster with the Data, Index, Query, and Eventing services enabled (NOTE: Index and Query are used in a future article). I am using a single node local install of Couchbase Sever EE but the information in this article applies to any Couchbase Server EE cluster.<\/p>\n\n\n\n<p>If you do not have an existing Couchbase Server EE cluster, the following links will get you up and running quickly:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.couchbase.com\/downloads\/\">Download Couchbase Sever EE 6.5<\/a><\/li>\n\n\n<li>Install Couchbase Server EE\n<ul>\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/install\/install-linux.html\">Linux<\/a><\/li>\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/install\/install-package-windows.html\">Windows<\/a><\/li>\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/install\/macos-install.html\">macOS<\/a><\/li>\n<\/ul>\n<\/li>\n\n\n<li><a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-nodes\/create-cluster.html#provision-a-node-with-the-ui\">Provision a single-node cluster<\/a>\u00a0(NOTE: use the default values for cluster configuration.)<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">JSON, BSON, and Extended JSON<\/h2>\n\n\n\n<p>MongoDB and Couchbase are both document databases and both store JSON documents. However, MongoDB represents JSON documents in binary-encoded format called BSON. JSON can only represent a subset of the types supported by BSON. To preserve type information, MongoDB uses Extended JSON which includes extensions to the JSON format. Refer to the <a href=\"https:\/\/github.com\/mongodb\/specifications\/blob\/master\/source\/extended-json.rst\">MongoDB Extended JSON specification<\/a> for full details on the different Extended JSON types and conventions.<\/p>\n\n\n\n<p>Here are some examples of how MongoDB represents different types of information:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ObjectId<\/strong>: &#8220;_id&#8221;:{&#8220;$oid&#8221;:&#8221;573a1390f29313caabcd4135&#8243;}<\/li>\n\n\n<li><strong>Integer<\/strong>: &#8220;runtime&#8221;:{&#8220;$numberInt&#8221;:&#8221;1&#8243;}<\/li>\n\n\n<li><strong>Date<\/strong>: &#8220;released&#8221;:{&#8220;$date&#8221;:{&#8220;$numberLong&#8221;:&#8221;-2418768000000&#8243;}}<\/li>\n\n\n<li><strong>Double<\/strong>: &#8220;rating&#8221;:{&#8220;$numberDouble&#8221;:&#8221;6.2&#8243;}<\/li>\n\n<\/ul>\n\n\n\n<p>While Couchbase can store this information, it is easier to work with documents that do not use the Extended JSON format. Using the above examples, the values would look like this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>ObjectId<\/strong>: &#8220;_id&#8221;:&#8221;573a1390f29313caabcd4135&#8243;<\/li>\n\n\n<li><strong>Integer<\/strong>: &#8220;runtime&#8221;:1<\/li>\n\n\n<li><strong>Date<\/strong>: &#8220;released&#8221;:-2418768000000<\/li>\n\n\n<li><strong>Double<\/strong>: &#8220;rating&#8221;:6.2<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Export Data from MongoDB<\/h2>\n\n\n\n<p>Use MongoDB Compass to export the <strong>movies<\/strong> and <strong>comments<\/strong> collections from the <strong>sample_mflix<\/strong> database. In Compass, expand the <strong>sample_mflix<\/strong> database item and then select <strong>comments<\/strong>.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8987\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/01.-Select-movies-and-comments-collection.png\" alt=\"\" width=\"248\" height=\"389\"><\/p>\n\n\n\n<p>Choose the <strong>Collection -&gt;\u00a0<\/strong><strong>Export Collection<\/strong> menu item. Select <strong>Export Full Collection<\/strong> and click <strong>SELECT FIELDS<\/strong>.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8988\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/02.-Export-full-collection.png\" alt=\"\" width=\"596\" height=\"320\"><\/p>\n\n\n\n<p>Select all fields and click <strong>SELECT OUTPUT<\/strong>.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8989\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/03.-Select-fields.png\" alt=\"\" width=\"598\" height=\"375\"><\/p>\n\n\n\n<p>Select <strong>JSON<\/strong> export file type, specify the Output file, and click <strong>EXPORT.<\/strong><\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8990\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/04.-Select-export-file-type.png\" alt=\"\" width=\"598\" height=\"330\"><\/p>\n\n\n\n<p>Do the same for the <strong>movies\u00a0<\/strong>collection.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Import Data to Couchbase<\/h2>\n\n\n\n<p>Next, import the MongoDB collection data into Couchbase. As mentioned above, the exported data is in Extended JSON Format so the Couchbase <a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-overview.html\">Eventing service<\/a> is used to do some minor transformations on the data in real time as the documents are imported into Couchbase.<\/p>\n\n\n\n<p>At a high level, the flow is as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Use the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/tools\/cbimport.html\">cbimport utility<\/a> to import the JSON documents into the <strong>incoming<\/strong> bucket.<\/li>\n\n\n<li>As documents are written to the <strong>incoming<\/strong> bucket, an Eventing function will transform the documents.<\/li>\n\n\n<li>If the transformation is successful, the transformed document with be written to the <strong>sample_mflix<\/strong>\u00a0bucket.<\/li>\n\n\n<li>If there are any errors, the original document is written to the <strong>error<\/strong>\u00a0bucket. An error attribute in the document will contain the error message.<\/li>\n\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Create Buckets<\/h2>\n\n\n\n<p>Create the three buckets mentioned above. Refer to the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/manage\/manage-buckets\/create-bucket.html\">documentation on creating a bucket<\/a> for full details on the different settings and considerations for setting the values.<\/p>\n\n\n\n<p>The <strong>incoming<\/strong> bucket will temporarily store the documents as they are imported into Couchbase. This is an <a href=\"https:\/\/docs.couchbase.com\/server\/current\/learn\/buckets-memory-and-storage\/buckets.html#bucket-types\">ephemeral bucket<\/a> since we don&#8217;t require any persistent storage for these documents. An Eventing function will transform them and write them to either the sample_mflix or error bucket.<\/p>\n\n\n\n<p>Since the documents do not need to remain in the bucket after they are transformed, the bucket is configured with a <a href=\"https:\/\/docs.couchbase.com\/server\/current\/learn\/buckets-memory-and-storage\/expiration.html\">Time To Live (TTL)<\/a> of 900 seconds (15 minutes). The documents are automatically deleted by Couchbase when the <a href=\"https:\/\/www.couchbase.com\/blog\/how-to-manage-ttl-with-couchbase-n1ql\/\">TTL<\/a> expires.<\/p>\n\n\n\n<p>To create the <strong>incoming<\/strong> bucket, click on <strong>Buckets<\/strong> and then <strong>ADD BUCKET<\/strong>.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8991\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/05.-Buckets-list-empty.png\" alt=\"\" width=\"1444\" height=\"566\"><\/p>\n\n\n\n<p>Configure the <strong>incoming<\/strong> bucket as follows and click <strong>Add Bucket<\/strong>.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Name<\/strong>: incoming<\/li>\n\n\n<li><strong>Memory Quota<\/strong>: 256 MB (NOTE: Ephemeral buckets do not persist to disk so you must ensure there is enough memory allocated to the bucket to accommodate the entire data set being imported. The total size of the comments and movies collections used in this example is about 50 MB so 256 MB is more than enough to accommodate this data set.)<\/li>\n\n\n<li><strong>Bucket Type<\/strong>: Ephemeral<\/li>\n\n\n<li><strong>Advanced Bucket Settings -&gt;\u00a0<\/strong><strong>Bucket Max Time-To-Live<\/strong>: 900 seconds (NOTE: The documents are transformed in real time as they are written to Couchbase so this value can be set relatively low. 15 minutes (900 seconds) is used in the case. If the value is set too low, the document could expire before it is processed.)<\/li>\n\n<\/ol>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8992\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/06.-incoming-bucket.png\" alt=\"\" width=\"530\" height=\"1142\"><\/p>\n\n\n\n<p>The <strong>sample_mflix<\/strong> bucket is used to store the transformed document. This is a <a href=\"https:\/\/docs.couchbase.com\/server\/current\/learn\/buckets-memory-and-storage\/buckets.html#bucket-types\">Couchbase bucket<\/a> since we require persistent storage for these documents. Configure it as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Name<\/strong>: sample_mflix<\/li>\n\n\n<li><strong>Memory Quota<\/strong>: 256 MB (NOTE: Couchbase buckets persist all documents to disk so the memory quota will determine how many documents can be stored in the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/learn\/buckets-memory-and-storage\/memory-and-storage.html\">integrated caching layer<\/a> at any time. The total size of the comments and movies collections used in this example is about 50 MB so 256 MB is more than enough to accommodate this data set.)<\/li>\n\n\n<li><strong>Bucket Type<\/strong>: Couchbase<\/li>\n\n<\/ol>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8993\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/07.-sample_mflix-bucket.png\" alt=\"\" width=\"530\" height=\"451\"><\/p>\n\n\n\n<p>The <strong>error<\/strong> bucket is used to store any documents that could not be transformed. Configure it as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Name<\/strong>: error<\/li>\n\n\n<li><strong>Memory Quota<\/strong>: 256 MB<\/li>\n\n\n<li><strong>Bucket Type<\/strong>: Couchbase<\/li>\n\n<\/ol>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8994\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/08.-error-bucket.png\" alt=\"\" width=\"530\" height=\"450\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Data Transformation with Eventing<\/h2>\n\n\n\n<p><a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-overview.html\">Eventing<\/a> is used to transform the data in real time as it is imported into Couchbase. There are a few things to configure to use this feature.<\/p>\n\n\n\n<p>First, create a <a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-Terminologies.html#buckets\"><strong>metadata<\/strong> bucket<\/a> that is used by Eventing to store system data. Configure it as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Name<\/strong>: metadata<\/li>\n\n\n<li><strong>Memory Quota<\/strong>: 256 MB<\/li>\n\n\n<li><strong>Bucket Type<\/strong>: Couchbase<\/li>\n\n<\/ol>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8995\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/09.-metadata-bucket.png\" alt=\"\" width=\"530\" height=\"451\"><\/p>\n\n\n\n<p>The <strong>Buckets<\/strong> section now lists the 4 buckets you created: error, incoming, metadata, &amp; sample_mflix:<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8996\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/10.-Buckets-list-4-buckets.png\" alt=\"\" width=\"1444\" height=\"566\"><\/p>\n\n\n\n<p>Click on <strong>Eventing<\/strong> and then click <strong>ADD FUNCTION<\/strong> to configure the function that is used to transform the data in real time as it is being imported into Couchbase.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8997\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/11.-Eventing-no-functions.png\" alt=\"\" width=\"1444\" height=\"566\"><\/p>\n\n\n\n<p>Configure the function as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Source Bucket<\/strong>: incoming (This bucket temporarily stores the documents as they are imported into Couchbase)<\/li>\n\n\n<li><strong>Metadata Bucket<\/strong>: metadata (This bucket is used to store system data)<\/li>\n\n\n<li><strong>Function Name<\/strong>: transform<\/li>\n\n\n<li><strong>Description<\/strong>: Transform MongoDB export<\/li>\n\n\n<li><strong>Bindings (<\/strong>Click the <strong>+<\/strong> icon to add a second binding)\n<ul>\n<li><strong>binding type<\/strong>: bucket alias<\/li>\n<li><strong>alias name<\/strong>: target (alias used in function to refer to bucket)<\/li>\n<li><strong>bucket<\/strong>: sample_mflix (name of the bucket in the cluster)<\/li>\n<li><strong>access:<\/strong> read and write<\/li>\n<\/ul>\n<\/li>\n\n<\/ol>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>binding type<\/strong>: bucket alias<\/li>\n\n\n<li><strong>alias name<\/strong>: error (alias used in function to refer to bucket)<\/li>\n\n\n<li><strong>bucket<\/strong>: error (name of the bucket in the cluster)<\/li>\n\n\n<li><strong>access:<\/strong> read and write<\/li>\n\n<\/ul>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8998\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/12.-transform-function.png\" alt=\"\" width=\"640\" height=\"692\"><\/p>\n\n\n\n<p>Click <strong>Next: Add Code<\/strong> to add the JavaScript code for the <strong>transform<\/strong> function.<\/p>\n\n\n\n<p>On the transform function screen, replace the boilerplate code with the code below.<\/p>\n\n\n\n<p>The function includes log() statements to log the original document, transformed document, and any errors. Feel free to change these as necessary. The entries Eventing log file is eventing.log can be found in the @eventing application log. See <a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-debugging-and-diagnosability.html#application-logs\">this link<\/a> for more information on the name of the log file and how to view them.<\/p>\n\n\n\n<p>You can easily extend the capability of this function to perform other transformations by adding the necessary code in the transformValues() function. If you need to make any changes to the function, you will need to <a href=\"https:\/\/docs.couchbase.com\/server\/current\/eventing\/eventing-lifecycle.html\">pause or undeploy it, edit the JavaScript, and then resume or deploy it again<\/a>.<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]function OnUpdate(doc, meta) {<br \/>\n    log(&#8220;original document: &#8220;, doc);<\/p>\n<p>    try {<br \/>\n      \/\/ transform document<br \/>\n      var newDoc = transformValues(null, &#8220;&#8221;, doc);<\/p>\n<p>      \/\/ add a type attribute based on the document ID (available in meta.id)<br \/>\n      newDoc[&#8220;type&#8221;] = getTypeFromId(meta.id);<\/p>\n<p>      \/\/ generate a document ID for the transformed document based on the type and the _id attribute value<br \/>\n      var id = generateId(newDoc);<br \/>\n      log(&#8220;transformed document (id = &#8221; + id + &#8220;): &#8220;, newDoc);<\/p>\n<p>      \/\/ write transformed document to target bucket with generated ID<br \/>\n      target[id] = newDoc;<br \/>\n    } catch (e) {<br \/>\n      log(&#8220;error transforming document &#8221; + meta.id + &#8220;. See error bucket for more details.&#8221;);<\/p>\n<p>      \/\/ if there are any errors, store error message in the error attribute<br \/>\n      doc[&#8220;error&#8221;] = e;<\/p>\n<p>      \/\/ write untransformed document to error bucket with original ID<br \/>\n      error[meta.id] = doc;<br \/>\n    }<br \/>\n}<\/p>\n<p>function OnDelete(meta) {<br \/>\n}<\/p>\n<p>\/\/ This is a recursive function that will iterate over all properties in the document (including arrays &amp; sub-objects)<br \/>\n\/\/ It will transform Extended JSON to standard JSON.<br \/>\nfunction transformValues(parentObj, parentProperty, obj) {<br \/>\n  var propertyType = &#8220;&#8221;;<\/p>\n<p>  \/\/ for every property in the object<br \/>\n  for (var property in obj) {<br \/>\n    if (obj.hasOwnProperty(property) &amp;&amp; obj[property] != null) {<br \/>\n      switch (property) {<br \/>\n        case &#8220;$oid&#8221;:<br \/>\n          \/\/ convert parentObj.parentProperty = {&#8220;$oid&#8221;:&#8221;3487634876&#8243;}<br \/>\n          \/\/ to parentObj.parentProperty = &#8220;3487634876&#8221;<br \/>\n          parentObj[parentProperty] = obj[property];<br \/>\n          break;<\/p>\n<p>        case &#8220;$date&#8221;:<br \/>\n          if (obj[&#8220;$date&#8221;][&#8220;$numberLong&#8221;] != null) {<br \/>\n            \/\/ convert parentObj.parentProperty = {&#8220;$date&#8221;:{&#8220;$numberLong&#8221;:&#8221;-2418768000000&#8243;}}<br \/>\n            \/\/ to parentObj.parentProperty = -2418768000000<br \/>\n            parentObj[parentProperty] = Number(obj[&#8220;$date&#8221;][&#8220;$numberLong&#8221;]);<br \/>\n            break;<br \/>\n          }<\/p>\n<p>          \/\/ convert parentObj.parentProperty = {&#8220;$date&#8221;:&#8221;1983-04-27T20:39:15Z&#8221;}}<br \/>\n          \/\/ to parentObj.parentProperty = &#8220;1983-04-27T20:39:15Z&#8221;<br \/>\n          parentObj[parentProperty] = obj[&#8220;$date&#8221;];<br \/>\n          break;<\/p>\n<p>        case &#8220;$numberInt&#8221;:<br \/>\n        case &#8220;$numberDecimal&#8221;:<br \/>\n        case &#8220;$numberLong&#8221;:<br \/>\n        case &#8220;$numberDouble&#8221;:<br \/>\n          \/\/ convert parentObj.parentProperty = {&#8220;$numberInt&#8221;:&#8221;1&#8243;}<br \/>\n          \/\/ to parentObj.parentProperty = 1<br \/>\n          parentObj[parentProperty] = Number(obj[property]);<br \/>\n          break;<\/p>\n<p>        \/\/ !!! This function can be extended by adding additional case statements here !!!<\/p>\n<p>        default:<br \/>\n          \/\/ otherwise, check the property type<br \/>\n          propertyType = determineType(obj[property]);<br \/>\n          switch (propertyType) {<br \/>\n            case &#8220;Object&#8221;:<br \/>\n              \/\/ if the property is an object, recursively transform the object<br \/>\n              transformValues(obj, property, obj[property]);<br \/>\n              break;<\/p>\n<p>            case &#8220;Array&#8221;:<br \/>\n              \/\/ if the property is an array, transform every element in the array<br \/>\n              transformArray(obj[property]);<br \/>\n              break;<\/p>\n<p>            default:<br \/>\n              \/\/ otherwise, do nothing<br \/>\n              break;<br \/>\n          }<br \/>\n      }<br \/>\n    }<br \/>\n  }<\/p>\n<p>  return obj;<br \/>\n}<\/p>\n<p>\/\/ Determine the type of the specified object<br \/>\nfunction determineType(obj) {<br \/>\n  return obj == null ? &#8220;null&#8221; : obj.constructor.name;<br \/>\n}<\/p>\n<p>\/\/ Transform every element in the specified array<br \/>\nfunction transformArray(obj) {<br \/>\n  for (var i = 0; i &lt; obj.length; i++) {<br \/>\n    transformValues(obj, i, obj[i]);<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/ Get document type from specified id.<br \/>\n\/\/ This function expects that documents will be imported with IDs in the following format:<br \/>\n\/\/ example: &lt;document type&gt;:12<br \/>\nfunction getTypeFromId(id) {<br \/>\n  return id.split(&#8220;:&#8221;)[0];<br \/>\n}<\/p>\n<p>\/\/ Generate a document ID for the specified document.<br \/>\n\/\/ The new ID will be based on the value of the type attribute and the value of the _id attribute:<br \/>\n\/\/ &lt;type&gt;:&lt;_id&gt;<br \/>\nfunction generateId(document) {<br \/>\n  var documentId = document[&#8220;_id&#8221;];<br \/>\n  if (determineType(documentId) != &#8220;String&#8221;) {<br \/>\n    throw &#8220;&#8216;_id&#8217; value must be a String: _id = &#8216;&#8221; + documentId + &#8220;&#8216;&#8221;;<br \/>\n  }<\/p>\n<p>  return document[&#8220;type&#8221;] + &#8220;:&#8221; + documentId;<br \/>\n}[\/crayon]<\/p>\n\n\n\n<p>Click <strong>Save<\/strong> to save the code and click <strong>&lt; back to Eventing<\/strong> to go back to the <strong>Eventing<\/strong> section of the console.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8999\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/13.-transform-code.png\" alt=\"\" width=\"1444\" height=\"756\"><\/p>\n\n\n\n<p>You will see the new <strong>transform<\/strong> function, but it needs to be deployed. Click on the <strong>transform<\/strong> function and then click <strong>Deploy<\/strong>.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9000\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/14.-Eventing-1-function-undeployed.png\" alt=\"\" width=\"1443\" height=\"566\"><\/p>\n\n\n\n<p>Confirm function deployment with the default setting by clicking <b>Deploy Function.<\/b><\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9001\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/15.-Deploy-transform-function.png\" alt=\"\" width=\"379\" height=\"258\"><\/p>\n\n\n\n<p>After the function deploys, the status is <strong>deployed<\/strong>.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9002\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/16.-Eventing-1-function-deployed.png\" alt=\"\" width=\"1439\" height=\"566\"><\/p>\n\n\n\n<p>Now everything is ready to import the MongoDB export data into Couchbase and transform it in real time.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Import Documents with cbimport<\/h2>\n\n\n\n<p>Use the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/tools\/cbimport-json.html\">cbimport utility<\/a> to import the MongoDB export files. Before importing data it is important to understand the command syntax and what it is doing.<\/p>\n\n\n\n<p>Here is an example cbimport command:<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]$ cbimport json -c &lt;cluster&gt; -u &lt;admin username&gt; -p &lt;admin password&gt; -b &lt;bucket&gt; -d &lt;import file&gt; -f &lt;file format&gt; -g &lt;key generator&gt;[\/crayon]<\/p>\n\n\n\n<p>To import the MongoDB <strong>comments<\/strong> collection, execute the command below. Note that the location of the cbimport utility varies based on the OS and is documented here: <a href=\"https:\/\/docs.couchbase.com\/server\/current\/cli\/cli-intro.html\">CLI Reference<\/a>.<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]$ &lt;path_to_cbimport&gt;\/cbimport json -c &lt;cluster&gt; -u &lt;admin username&gt; -p &lt;admin password&gt; -b incoming -d file:\/\/&lt;path to comments.json&gt;\/comments.json -f list -g comment:#MONO_INCR#[\/crayon]<\/p>\n\n\n\n<p>The command will connect to the specified cluster (i.e. -c couchbase:\/\/127.0.0.1) using the supplied Administrator credentials (i.e. -u Administrator -p password).<\/p>\n\n\n\n<p>The command will import JSON data from comments.json. Check the format of the exported comments.json file and specify the correct <a href=\"https:\/\/docs.couchbase.com\/server\/current\/tools\/cbimport-json.html#dataset-formats\">dataset format option<\/a> based on the export file format. My export file follows the <a href=\"https:\/\/docs.couchbase.com\/server\/current\/tools\/cbimport-json.html#list\">list format<\/a> which contains a single JSON list where each element in the list represents a separate document (-f list).<\/p>\n\n\n\n<p>The documents are written to the incoming bucket (-b incoming) using a key generated using the specified format (-g comment:#MONO_INCR#). In this command the format specifies that each document key will start with &#8220;comment:&#8221;. The <a href=\"https:\/\/docs.couchbase.com\/server\/current\/tools\/cbimport-json.html#key-generators\">MONO_INCR function<\/a> increments by 1 each time it is called so the resulting keys are comment:1, comment:2, etc.<\/p>\n\n\n\n<p>Upon completion you will see the following output:<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]Json `file:\/\/comments.json` imported to `https:\/\/127.0.0.1:8091` successfully.<br \/>\nDocuments imported: 50304 Documents failed: 0[\/crayon]<\/p>\n\n\n\n<p>Go to the <strong>Buckets<\/strong> section and confirm that the <strong>sample_mflix<\/strong> bucket contains 50,304 documents.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9003\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/17.-Buckets-after-comments-import.png\" alt=\"\" width=\"1443\" height=\"566\"><\/p>\n\n\n\n<p>To import the MongoDB <strong>movies<\/strong> collection, execute the command below.<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]$ &lt;path_to_cbimport&gt;\/cbimport json -c &lt;cluster&gt; -u &lt;admin username&gt; -p &lt;admin password&gt; -b incoming -d file:\/\/&lt;path to movies.json&gt;\/movies.json -f list -g movie:#MONO_INCR#[\/crayon]<\/p>\n\n\n\n<p>Upon completion you will see the following output:<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]Json `file:\/\/movies.json` imported to `https:\/\/127.0.0.1:8091` successfully.<br \/>\nDocuments imported: 23539 Documents failed: 0[\/crayon]<\/p>\n\n\n\n<p>Go to the <strong>Buckets<\/strong> section and confirm that the <strong>sample_mflix<\/strong> bucket contains 73,843 documents.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9004\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/18.-Buckets-after-movies-import.png\" alt=\"\" width=\"1442\" height=\"566\"><\/p>\n\n\n\n<p>Now check two of the transformed documents. Go to the <strong>Documents<\/strong> section and make sure that the <strong>Bucket<\/strong> is set to <strong>sample_mflix<\/strong>. Click on id <strong>comment:5a9427648b0beebeb69579cc<\/strong> (the first document in the list):<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9005\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/19.-sample_mflix-documents.png\" alt=\"\" width=\"1443\" height=\"566\"><\/p>\n\n\n\n<p>Note the contents:<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]{<br \/>\n  &#8220;_id&#8221;: &#8220;5a9427648b0beebeb69579cc&#8221;,<br \/>\n  &#8220;name&#8221;: &#8220;Andrea Le&#8221;,<br \/>\n  &#8220;email&#8221;: &#8220;andrea_le@fakegmail.com&#8221;,<br \/>\n  &#8220;movie_id&#8221;: &#8220;573a1390f29313caabcd418c&#8221;,<br \/>\n  &#8220;text&#8221;: &#8220;Rem officiis eaque repellendus amet eos doloribus. Porro dolor voluptatum voluptates neque culpa molestias. Voluptate unde nulla temporibus ullam.&#8221;,<br \/>\n  &#8220;date&#8221;: &#8220;2012-03-26T23:20:16Z&#8221;,<br \/>\n  &#8220;type&#8221;: &#8220;comment&#8221;<br \/>\n}[\/crayon]<\/p>\n\n\n\n<p>Comparing it to the exported data (search for 5a9427648b0beebeb69579cc in comments.json):<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]{<br \/>\n  &#8220;_id&#8221;:{&#8220;$oid&#8221;:&#8221;5a9427648b0beebeb69579cc&#8221;},<br \/>\n  &#8220;name&#8221;:&#8221;Andrea Le&#8221;,<br \/>\n  &#8220;email&#8221;:&#8221;andrea_le@fakegmail.com&#8221;,<br \/>\n  &#8220;movie_id&#8221;:{&#8220;$oid&#8221;:&#8221;573a1390f29313caabcd418c&#8221;},<br \/>\n  &#8220;text&#8221;:&#8221;Rem officiis eaque repellendus amet eos doloribus. Porro dolor voluptatum voluptates neque culpa molestias. Voluptate unde nulla temporibus ullam.&#8221;,<br \/>\n  &#8220;date&#8221;: {&#8220;$date&#8221;: &#8220;2012-03-26T23:20:16Z&#8221;}<br \/>\n}[\/crayon]<\/p>\n\n\n\n<p>The transform function has changed the Extended JSON _id, movie_id, &amp; date values. Note that a type attribute was added based on the document key prefix (remember that we specified comment as the key prefix when importing the data).<\/p>\n\n\n\n<p>Close the document editor when you are finished reviewing the contents of the document.<\/p>\n\n\n\n<p>In the <strong>Document ID<\/strong> field enter <strong>movie:573a1390f29313caabcd4135<\/strong>, click <strong>Retrieve Docs<\/strong>, and click on id <strong>movie:573a1390f29313caabcd4135<\/strong>.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-9006\" src=\"https:\/\/www.couchbase.com\/wp-content\/uploads\/sites\/5\/2026\/05\/20.-movie-document.png\" alt=\"\" width=\"1443\" height=\"566\"><\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><\/h4>\n\n\n\n<p>Note the contents:<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]{<br \/>\n  &#8220;_id&#8221;: &#8220;573a1390f29313caabcd4135&#8221;,<br \/>\n  &#8220;plot&#8221;: &#8220;Three men hammer on an anvil \u2026&#8221;,<br \/>\n  &#8220;genres&#8221;: [ &#8220;Short&#8221; ],<br \/>\n  &#8220;runtime&#8221;: 1,<br \/>\n  &#8220;cast&#8221;: [ &#8220;Charles Kayser&#8221;, &#8220;John Ott&#8221; ],<br \/>\n  &#8220;num_mflix_comments&#8221;: 1,<br \/>\n  &#8220;title&#8221;: &#8220;Blacksmith Scene&#8221;,<br \/>\n  &#8220;fullplot&#8221;: &#8220;A stationary camera looks at a large anvil \u2026&#8221;,<br \/>\n  &#8220;countries&#8221;: [ &#8220;USA&#8221; ],<br \/>\n  &#8220;released&#8221;: -2418768000000,<br \/>\n  &#8220;directors&#8221;: [ &#8220;William K.L. Dickson&#8221; ],<br \/>\n  &#8220;rated&#8221;: &#8220;UNRATED&#8221;,<br \/>\n  &#8220;awards&#8221;: {<br \/>\n    &#8220;wins&#8221;: 1,<br \/>\n    &#8220;nominations&#8221;: 0,<br \/>\n    &#8220;text&#8221;: &#8220;1 win.&#8221;<br \/>\n  },<br \/>\n  &#8220;lastupdated&#8221;: &#8220;2015-08-26 00:03:50.133000000&#8221;,<br \/>\n  &#8220;year&#8221;: 1893,<br \/>\n  &#8220;imdb&#8221;: {<br \/>\n    &#8220;rating&#8221;: 6.2,<br \/>\n    &#8220;votes&#8221;: 1189,<br \/>\n    &#8220;id&#8221;: 5<br \/>\n  },<br \/>\n  &#8220;type&#8221;: &#8220;movie&#8221;,<br \/>\n  &#8220;tomatoes&#8221;: {<br \/>\n    &#8220;viewer&#8221;: {<br \/>\n      &#8220;rating&#8221;: 3,<br \/>\n      &#8220;numReviews&#8221;: 184,<br \/>\n      &#8220;meter&#8221;: 32<br \/>\n    },<br \/>\n    &#8220;lastUpdated&#8221;: &#8220;2015-06-28T18:34:09Z&#8221;<br \/>\n  }<br \/>\n}[\/crayon]<\/p>\n\n\n\n<p>Comparing it to the exported data (search for 573a1390f29313caabcd4135 in movies.json):<\/p>\n\n\n<p>[crayon lang=&#8221;default&#8221; decode=&#8221;true&#8221;]{<br \/>\n  &#8220;_id&#8221;: {&#8220;$oid&#8221;: &#8220;573a1390f29313caabcd4135&#8221;},<br \/>\n  &#8220;plot&#8221;: &#8220;Three men hammer on an \u2026&#8221;,<br \/>\n  &#8220;genres&#8221;: [ &#8220;Short&#8221; ],<br \/>\n  &#8220;runtime&#8221;: 1,<br \/>\n  &#8220;cast&#8221;: [ &#8220;Charles Kayser&#8221;, &#8220;John Ott&#8221; ],<br \/>\n  &#8220;num_mflix_comments&#8221;: 1,<br \/>\n  &#8220;title&#8221;: &#8220;Blacksmith Scene&#8221;,<br \/>\n  &#8220;fullplot&#8221;: &#8220;A stationary camera looks at a large anvil \u2026&#8221;,<br \/>\n  &#8220;countries&#8221;: [ &#8220;USA&#8221; ],<br \/>\n  &#8220;released&#8221;: {&#8220;$date&#8221;: {&#8220;$numberLong&#8221;: &#8220;-2418768000000&#8221;}},<br \/>\n  &#8220;directors&#8221;:[ &#8220;William K.L. Dickson&#8221; ],<br \/>\n  &#8220;rated&#8221;: &#8220;UNRATED&#8221;,<br \/>\n  &#8220;awards&#8221;: {<br \/>\n    &#8220;wins&#8221;: 1,<br \/>\n    &#8220;nominations&#8221;: 0,<br \/>\n    &#8220;text&#8221;: &#8220;1 win.&#8221;<br \/>\n  },<br \/>\n  &#8220;lastupdated&#8221;: &#8220;2015-08-26 00:03:50.133000000&#8221;,<br \/>\n  &#8220;year&#8221;: 1893,<br \/>\n  &#8220;imdb&#8221;: {<br \/>\n    &#8220;rating&#8221;: 6.2,<br \/>\n    &#8220;votes&#8221;: 1189,<br \/>\n    &#8220;id&#8221;: 5<br \/>\n  },<br \/>\n  &#8220;type&#8221;: &#8220;movie&#8221;,<br \/>\n  &#8220;tomatoes&#8221;: {<br \/>\n    &#8220;viewer&#8221;: {<br \/>\n      &#8220;rating&#8221;: 3,<br \/>\n      &#8220;numReviews&#8221; 184,<br \/>\n      &#8220;meter&#8221;: 32<br \/>\n    },<br \/>\n    &#8220;lastUpdated&#8221;: {&#8220;$date&#8221;: &#8220;2015-06-28T18:34:09Z&#8221;}<br \/>\n  }<br \/>\n}[\/crayon]<\/p>\n\n\n\n<p>The transform function has changed the Extended JSON _id, released, &amp; tomatoes.lastUpdated values.\u00a0Note that a type attribute was not added in this case. The exported document already contained a type attribute, so the transform function did not add one but set the value based on the key prefix (remember that we specified movie as the key prefix when importing the data).<\/p>\n\n\n\n<p>Close the document editor when you are finished reviewing the contents of the document.<\/p>\n\n\n\n<p><strong>What&#8217;s Next<\/strong><\/p>\n\n\n\n<p>If you do not plan to import any more MongoDB export data, you can undeploy the transform function and remove the incoming and error buckets.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A future article will cover how to update existing client code to use the Couchbase SDK.<\/li>\n\n\n<li>Take advantage of our free, online training available at <a href=\"https:\/\/learn.couchbase.com\/\">https:\/\/learn.couchbase.com<\/a> to learn more about Couchbase.<\/li>\n\n\n<li>Check out the various <a href=\"https:\/\/docs.couchbase.com\/server\/current\/develop\/integrations.html#ide-integrations\">Couchbase developer IDEs\u2014JetBrains, VSCode<\/a>\u2014that we have plugins for.<\/li>\n\n<\/ul>\n\n\n\n<p>For detailed information about the different document models between Couchbase and MongoDB, data modeling and MongoDB schema, and other ways of comparing MongoDB vs. Couchbase, see this document: <a href=\"https:\/\/drive.google.com\/file\/d\/14YQuCAGSsvNcnlBJkM6QnnLNzo3GadTk\/view\">Couchbase: Better Than MongoDB In Every Way<\/a>.<\/p>\n\n\n\n<p>Learn why other enterprises choose Couchbase over MongoDB:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/www.couchbase.com\/customers\/directv\/\">DIRECTV<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.couchbase.com\/customers\/viber\/\">Viber<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.couchbase.com\/customers\/nuance\/\">Nuance<\/a><\/li>\n\n\n<li><a href=\"https:\/\/www.youtube.com\/watch?list=PLcspbWiU9RuunKnZwfE757B6-xsaiJV84&amp;time_continue=2&amp;v=UD_4zuga1kk\">Staples<\/a><\/li>\n\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Prologue This article guides you through a one-time MongoDB migration to Couchbase. You will learn how to export from the MongoDB data structure, import to Couchbase, and do some basic transformation on those documents. All code from this blog is available in the following Git repository: mongodb-to-couchbase Prerequisites This article uses the sample mflix dataset [&hellip;]<\/p>\n","protected":false},"author":1352,"featured_media":1529,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[136,54,189,348],"tags":[44],"ppma_author":[363],"class_list":["post-1530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-best-practices-and-tutorials","category-couchbase-server","category-data-modeling","category-eventing","tag-mongodb"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.6 (Yoast SEO v27.6) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>How to Migrate MongoDB Database to Couchbase - Prerequisites<\/title>\n<meta name=\"description\" content=\"Need to know how to migrate MongoDB database to Couchbase? This blog post will help to guide you through the basics of a one-time MongoDB migration.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.couchbase.com\/blog\/migrating-data-from-mongodb-to-couchbase\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Migrating Data from MongoDB to Couchbase\" \/>\n<meta property=\"og:description\" content=\"Need to know how to migrate MongoDB database to Couchbase? This blog post will help to guide you through the basics of a one-time MongoDB migration.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.couchbase.com\/blog\/migrating-data-from-mongodb-to-couchbase\/\" \/>\n<meta property=\"og:site_name\" content=\"The Couchbase Blog\" \/>\n<meta property=\"article:published_time\" content=\"2020-07-31T05:17:30+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/mongodb-to-couchbase-blogbanner.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1575\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Douglas Bonser, Principal Solution Engineer, Couchbase\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Douglas Bonser, Principal Solution Engineer, Couchbase\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/\"},\"author\":{\"name\":\"Douglas Bonser, Principal Solution Engineer, Couchbase\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/7fdd6feab8e25100caf61bb7836ee0ff\"},\"headline\":\"Migrating Data from MongoDB to Couchbase\",\"datePublished\":\"2020-07-31T05:17:30+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/\"},\"wordCount\":2842,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/mongodb-to-couchbase-blogbanner.jpg\",\"keywords\":[\"mongodb\"],\"articleSection\":[\"Best Practices and Tutorials\",\"Couchbase Server\",\"Data Modeling\",\"Eventing\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/\",\"name\":\"How to Migrate MongoDB Database to Couchbase - Prerequisites\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/mongodb-to-couchbase-blogbanner.jpg\",\"datePublished\":\"2020-07-31T05:17:30+00:00\",\"description\":\"Need to know how to migrate MongoDB database to Couchbase? This blog post will help to guide you through the basics of a one-time MongoDB migration.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/#primaryimage\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/mongodb-to-couchbase-blogbanner.jpg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/05\\\/mongodb-to-couchbase-blogbanner.jpg\",\"width\":1575,\"height\":628},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/es\\\/migrating-data-from-mongodb-to-couchbase\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Migrating Data from MongoDB to Couchbase\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"name\":\"The Couchbase Blog\",\"description\":\"Couchbase, the NoSQL Database\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#organization\",\"name\":\"The Couchbase Blog\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"contentUrl\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/wp-content\\\/uploads\\\/sites\\\/5\\\/2026\\\/06\\\/logo.svg\",\"width\":\"1024\",\"height\":\"1024\",\"caption\":\"The Couchbase Blog\"},\"image\":{\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/#\\\/schema\\\/person\\\/7fdd6feab8e25100caf61bb7836ee0ff\",\"name\":\"Douglas Bonser, Principal Solution Engineer, Couchbase\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/68f7547e24c39852e700940d8209edf75f6b9cd64ba057ce1e11313d9230ab84?s=96&d=mm&r=ge922810e11bd43dd211ba0ee960f9738\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/68f7547e24c39852e700940d8209edf75f6b9cd64ba057ce1e11313d9230ab84?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/68f7547e24c39852e700940d8209edf75f6b9cd64ba057ce1e11313d9230ab84?s=96&d=mm&r=g\",\"caption\":\"Douglas Bonser, Principal Solution Engineer, Couchbase\"},\"description\":\"Douglas Bonser is a Principal Solutions Engineer at Couchbase and has been working in IT and technology since 1991. He is based in the Dallas\\\/Ft. Worth area.\",\"url\":\"https:\\\/\\\/www.couchbase.com\\\/blog\\\/author\\\/douglas-bonsercouchbase-com\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"How to Migrate MongoDB Database to Couchbase - Prerequisites","description":"Need to know how to migrate MongoDB database to Couchbase? This blog post will help to guide you through the basics of a one-time MongoDB migration.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.couchbase.com\/blog\/migrating-data-from-mongodb-to-couchbase\/","og_locale":"en_US","og_type":"article","og_title":"Migrating Data from MongoDB to Couchbase","og_description":"Need to know how to migrate MongoDB database to Couchbase? This blog post will help to guide you through the basics of a one-time MongoDB migration.","og_url":"https:\/\/www.couchbase.com\/blog\/migrating-data-from-mongodb-to-couchbase\/","og_site_name":"The Couchbase Blog","article_published_time":"2020-07-31T05:17:30+00:00","og_image":[{"width":1575,"height":628,"url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/mongodb-to-couchbase-blogbanner.jpg","type":"image\/jpeg"}],"author":"Douglas Bonser, Principal Solution Engineer, Couchbase","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Douglas Bonser, Principal Solution Engineer, Couchbase","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/#article","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/"},"author":{"name":"Douglas Bonser, Principal Solution Engineer, Couchbase","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/7fdd6feab8e25100caf61bb7836ee0ff"},"headline":"Migrating Data from MongoDB to Couchbase","datePublished":"2020-07-31T05:17:30+00:00","mainEntityOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/"},"wordCount":2842,"commentCount":0,"publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/mongodb-to-couchbase-blogbanner.jpg","keywords":["mongodb"],"articleSection":["Best Practices and Tutorials","Couchbase Server","Data Modeling","Eventing"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/","url":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/","name":"How to Migrate MongoDB Database to Couchbase - Prerequisites","isPartOf":{"@id":"https:\/\/www.couchbase.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/#primaryimage"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/#primaryimage"},"thumbnailUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/mongodb-to-couchbase-blogbanner.jpg","datePublished":"2020-07-31T05:17:30+00:00","description":"Need to know how to migrate MongoDB database to Couchbase? This blog post will help to guide you through the basics of a one-time MongoDB migration.","breadcrumb":{"@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/#primaryimage","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/mongodb-to-couchbase-blogbanner.jpg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/05\/mongodb-to-couchbase-blogbanner.jpg","width":1575,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/www.couchbase.com\/blog\/es\/migrating-data-from-mongodb-to-couchbase\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.couchbase.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Migrating Data from MongoDB to Couchbase"}]},{"@type":"WebSite","@id":"https:\/\/www.couchbase.com\/blog\/#website","url":"https:\/\/www.couchbase.com\/blog\/","name":"The Couchbase Blog","description":"Couchbase, the NoSQL Database","publisher":{"@id":"https:\/\/www.couchbase.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.couchbase.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.couchbase.com\/blog\/#organization","name":"The Couchbase Blog","url":"https:\/\/www.couchbase.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","contentUrl":"https:\/\/www.couchbase.com\/blog\/wp-content\/uploads\/sites\/5\/2026\/06\/logo.svg","width":"1024","height":"1024","caption":"The Couchbase Blog"},"image":{"@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.couchbase.com\/blog\/#\/schema\/person\/7fdd6feab8e25100caf61bb7836ee0ff","name":"Douglas Bonser, Principal Solution Engineer, Couchbase","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/68f7547e24c39852e700940d8209edf75f6b9cd64ba057ce1e11313d9230ab84?s=96&d=mm&r=ge922810e11bd43dd211ba0ee960f9738","url":"https:\/\/secure.gravatar.com\/avatar\/68f7547e24c39852e700940d8209edf75f6b9cd64ba057ce1e11313d9230ab84?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/68f7547e24c39852e700940d8209edf75f6b9cd64ba057ce1e11313d9230ab84?s=96&d=mm&r=g","caption":"Douglas Bonser, Principal Solution Engineer, Couchbase"},"description":"Douglas Bonser is a Principal Solutions Engineer at Couchbase and has been working in IT and technology since 1991. He is based in the Dallas\/Ft. Worth area.","url":"https:\/\/www.couchbase.com\/blog\/author\/douglas-bonsercouchbase-com\/"}]}},"acf":[],"authors":[{"term_id":363,"user_id":1352,"is_guest":0,"slug":"douglas-bonsercouchbase-com","display_name":"Douglas Bonser, Principal Solution Engineer, Couchbase","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/users\/1352"}],"replies":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/comments?post=1530"}],"version-history":[{"count":0,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/posts\/1530\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media\/1529"}],"wp:attachment":[{"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/media?parent=1530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/categories?post=1530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/tags?post=1530"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.couchbase.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=1530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}