1

I'm developing node.js application that should work both on a powerful server and on a weak android device.

In the server to access the database I'm going to use mongoose.

And what use for android? The android application must operate autonomously and database must be inside the device.

Is there a library similar to mongoose that stores objects in a simple json-file and performs the simplest operations to extract data from it?

ArkadiBernov
  • 570
  • 8
  • 13
  • For this problem you need fs module.And you should [read this article](https://stackoverflow.com/questions/19706046/how-to-read-an-external-local-json-file-in-javascript) – ŞükSefHam Mar 31 '18 at 21:35
  • Yes, but need not only to read data from a json-file, also need to implement many methods that are in mongoose, for example findById. Is not there already such a library? – ArkadiBernov Mar 31 '18 at 21:53

1 Answers1

0

With fs module you can read,and write on json file.you want findbyid?

var a=[{id:1,topic:"you"},{id:2,topic:"im"},{id:1,topic:"you2"}];var z=[];var b=1;   

for (var i=0;i<a.length;i++){ if(b==a[i].id){z.push(a[i].topic) } }//now z =["you","you2"]

ŞükSefHam
  • 167
  • 1
  • 10