Skip to content

BoJacobs/mongo-data-importer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

mongo-data-importer

A Spring tool that allows you to import data in MongoDB from data files on the classpath.

In the future, CSV support will be added.

Getting started

Coming soon.

Usage

To use the tool, you need to instantiate a MongoJSONImporter object. Using Spring, you can instantiate the importer as a bean in the Spring context.

@Bean
public MongoJSONImporter mongoJSONImporter(){
  MongoJSONImporter importer = new MongoJSONImporter("mongodb://DBHOST:DBPORT/DBNAME", new DefaultResourceLoader());

  return importer;
}

The tool will look for .json files in a 'data' directory on the classpath and create collections with the same name as the file.

The JSON files should define an array of objects. Example:

[
  {
    "name": "record1Name",
    "anotherField": "anotherValue1",
    "nestedObject": {
      "nestedField:" : 1
    }
  },
  {
    "name": "record2Name",
    "anotherField": "anotherValue2",
    "arrayField": [
      "val1",
      "val2"
    ]
  },
  ...
]

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages