louischatriot / nedb

The JavaScript Database, for Node.js, nw.js, electron and the browser
MIT License
13.49k stars 1.03k forks source link

Nedb data export to excel/csv formats ? #518

Open Technologeek opened 7 years ago

Technologeek commented 7 years ago

First off,Thanks @louischatriot for the amazing work on Nedb.I have been using Nedb on a project without any issues till date.I'm close to completing my project and I'm stuck at a following limitation of nedb.I need to export my data(data store) to either of text/csv format as according to my clients requirements. Unlike nedb,monogodb provides an export method,almost all the major databases do.My question is : Does Nedb has a feature or a trick where I can export the data in the mentioned formats ? The way data is stored is not even complete JSON so using native javascript plugins don't help.Has anybody made it work yet ? Thanks in Advance !

marcusjwhelan commented 7 years ago

You could simply write a method yourself to load in each obj to memory and pipe it out to JSON.

JamesMGreene commented 7 years ago

By default, a persistent NeDB datafile's format is ndjson (newline-delimited JSON). However, the moment you add a custom afterSerialization and beforeDeserialization hook functions, that default format completely goes out the window at the whim of your hook functions.

But otherwise, @marcusjwhelan said it right: just create your own. It's pretty simple. You can publish them as standalone modules like nedb-export and nedb-import. MongoDB's mongoimport and mongoexport are external tools like that, too.

xeoshow commented 6 years ago

Very helpful, thanks