0

I'm working on a twitter bot that is supposed to search the twitter api for key words in intervals and log the response in a database. I've so far logged results in a simple JSON but want to move to NeDB. I keep running into this error (shortened) while attempting to only have unique records stored:

Error: Cannot create an index without a fieldName at Datastore.ensureIndex { missingFieldName: true }

The code in question reads as follows:

async function logCleanTweets(array) {
  db.insert(array);
  db.ensureIndex({fieldname: 'id', unique: true}, function (err) {console.log(err);});
  db.persistence.compactDatafile();
  return uniqueArray.length
}

Thank you for your help!

0 Answers0