0

The following TaffyDB script successfully outputs the entire database:

db().each(function (name){
var bodyType=(name["bodyType"]);
var category=(name["category"]);
var name2=(name["name2"]);
var photo=(name["photo"]);
var resource=(name["resource"]);
var caption=(name["caption"]);
output = document.getElementById("display");
output.innerHTML+="<div class='segment'><p class='title'>" + bodyType + ": " + name2 + "</p>" +
"<img class='pic' src='" + photo + "' width='150px'>" +
"<p class='caption'>" + caption + "</p>" +
"<p class='more'><a href='" + resource + "'>More</a></p></div>";
});

My question is about how to filter the contents. The site has this code:

db().filter({column:value});

How do I change the top code to integrate it?

db().filter({bodyType:buggy});

This does not work:

db().each(function (name){
var bodyType=(name["bodyType"]);
var category=(name["category"]);
var name2=(name["name2"]);
var photo=(name["photo"]);
var resource=(name["resource"]);
var caption=(name["caption"]);
db().filter({bodyType:buggy});
output = document.getElementById("display");
output.innerHTML+="<div class='segment'><p class='title'>" + bodyType + ": " + name2 + "</p>" +
"<img class='pic' src='" + photo + "' width='150px'>" +
"<p class='caption'>" + caption + "</p>" +
"<p class='more'><a href='" + resource + "'>More</a></p></div>";
});
4

1 回答 1

0

以这种方式更改第一行:

db({bodyType:"Buggy"}).each(function (name){
于 2015-01-07T22:34:26.177 回答