TryGhost/Ghost — pull request #1394 by jgable (2013-11-03 17:18:17+00:00)
Title: Add importJSONData to api/db.js for import plugins

- Abstract out the common functionality from the existing
import function.
- Refactor to remove circular ghost and api references so we can add
unit tests.
- Add unit tests for getVersion() and importJSONData()

While working on the [Wordpress Import Plugin](https://github.com/jgable/ghost-plugin/blob/wordpressImport/example/WordpressImport/index.js) I needed a way to import the parsed data and didn't have access to the req, res objects. This change will make it easier for our import plugins to use the existing db import functionality.

```javascript
}).then(function (ghostImportFormatData) {
// Inject data using import api
return self.app.api.db.importJSONData(ghostImportFormatData);
});
```