Skip to content

JSON file requires "_id" for find(querry) to return all filtered results #36

Description

@neilmahaseth

I was using a custom made JSON file with "id" key instead of "_id". This caused the find(query) method to return only the first matched result.

example articles.json

[
{
"title": "diskDB rocks again",
"published": "3 days ago",
"rating": 3,
"id": "1"
},
{
"title": "diskDB rocks again",
"published": "3 days ago",
"rating": 2,
"id": "2"
},
{
"title": "diskDB rocks again",
"published": "3 days ago",
"rating": 4,
"id": "3"
},
{
"title": "diskDB rocks again",
"published": "3 days ago",
"rating": 2,
"id": "4"
},
{
"title": "diskDB rocks",
"published": "2 days ago",
"rating": 2,
"id": "5"
}
]

var db = require('diskdb');
db.connect('.', ['articles']);
articleComments4, articleComments5]);
var foundArticles = db.articles.find();
var foundArticles = db.articles.find({rating : 2});

console.log(foundArticles);
console.log(foundArticles.length);

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions