How to find items that are in one dstore collection but not in another?

Allen Zhang

Suppose I have two dstore collections: value1 and value2.

I want to find out what items are in value1 but not in value2. So something like this:

var filterCollection = value1.filter(function(item) {
    return value2.notExists(item);
});

But "notExists" function, well, doesn't exist. How do I make this logic work?

GibboK

As this feature is not included by default in dstore, you can write your own function for comparing the content of your dstores and use the result as you wish.

Here a generic example. You need to populate value1 and value1 with the content of your dstore.

Simplified example.

http://jsbin.com/fozeqamide/edit?html,console,output

Version without using indexOf()

http://jsbin.com/nihelejodo/edit?html,console,output

The way how you loop in your datastore is related to its data structure.

Notes: This is a generic example as the question does not provide any source code, nor an example of data in dstore.

<!doctype html>

<html lang="en">
<head>
    <meta charset="utf-8">
    <title>Builder</title>
    <style>
    </style>
    <script>
        window.app = {
            value1: [1, 2, 3, 4, 5, 6, 4, 8], // populate with date for valu1 dstore
            value2: [1, 2, 6, 4, 8], // populate with date for valu1 dstore
            valueNotExists: [],
            start: function () {
                this.notExists();
            },
            notExists: function () {
                this.valueNotExists = this.value1.filter(function (x) {
                    return this.value2.indexOf(x) < 0;
                }.bind(this));
                console.log(this.valueNotExists);
            },
        };
    </script>

</head>

<body onload="window.app.start();">

</body>
</html>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to sort a collection of points so that they set up one after another?

From Dev

How to read a collection that depends on another one in Meteor

From Dev

Ordering a collection by another one

From Dev

node, mongoose 'findOne' on one collection inside 'find' of another collection

From Dev

How to copy only new items from one list to another

From Dev

How can I remove all items from a Dojo dstore?

From Dev

How to filter one list of items from another list of items?

From Dev

How to check if a portion of an _id from one collection appears in another

From Dev

dstore ( dojo ) event (add) misfiring on collection

From Dev

How to find all objects with an attribute that matches any of the values in another collection?

From Dev

Update one collection based on another collection value

From Dev

Meteor using a collection.find() in another collection

From Dev

MongoDB, Mongoose results from one Find to search another collection

From Dev

How to check if one collection only contains elements from another collection?

From Dev

how to copy a collection from one from another in robomongo

From Dev

How to transfer items of one static list to another

From Dev

How to find all records if one property is equal to another one

From Dev

find items in javascript object array where one of the properties does not match items in another array

From Dev

Remove items from a collection if one date is greater than another

From Dev

How to find all objects with an attribute that matches any of the values in another collection?

From Dev

How to move Items from one list to the another list in python?

From Dev

Meteor.js moving items from one collection to another

From Dev

how to copy a collection from one from another in robomongo

From Dev

How to detect that one field of collection exist into another list with linq?

From Dev

How to move items/buttons from one div to another using JQuery?

From Dev

How to get data from one collection and insert into another collection in Nodejs?

From Dev

How do items in an object from one function transfer into another function?

From Dev

Filtering dstore collection against an array field

From Dev

How to model a collection of items where one of them is the active item?

Related Related

  1. 1

    How to sort a collection of points so that they set up one after another?

  2. 2

    How to read a collection that depends on another one in Meteor

  3. 3

    Ordering a collection by another one

  4. 4

    node, mongoose 'findOne' on one collection inside 'find' of another collection

  5. 5

    How to copy only new items from one list to another

  6. 6

    How can I remove all items from a Dojo dstore?

  7. 7

    How to filter one list of items from another list of items?

  8. 8

    How to check if a portion of an _id from one collection appears in another

  9. 9

    dstore ( dojo ) event (add) misfiring on collection

  10. 10

    How to find all objects with an attribute that matches any of the values in another collection?

  11. 11

    Update one collection based on another collection value

  12. 12

    Meteor using a collection.find() in another collection

  13. 13

    MongoDB, Mongoose results from one Find to search another collection

  14. 14

    How to check if one collection only contains elements from another collection?

  15. 15

    how to copy a collection from one from another in robomongo

  16. 16

    How to transfer items of one static list to another

  17. 17

    How to find all records if one property is equal to another one

  18. 18

    find items in javascript object array where one of the properties does not match items in another array

  19. 19

    Remove items from a collection if one date is greater than another

  20. 20

    How to find all objects with an attribute that matches any of the values in another collection?

  21. 21

    How to move Items from one list to the another list in python?

  22. 22

    Meteor.js moving items from one collection to another

  23. 23

    how to copy a collection from one from another in robomongo

  24. 24

    How to detect that one field of collection exist into another list with linq?

  25. 25

    How to move items/buttons from one div to another using JQuery?

  26. 26

    How to get data from one collection and insert into another collection in Nodejs?

  27. 27

    How do items in an object from one function transfer into another function?

  28. 28

    Filtering dstore collection against an array field

  29. 29

    How to model a collection of items where one of them is the active item?

HotTag

Archive