top of page

Already took a look into CONSOLE ???

In this example you will see how -->  .distinct()   <--- is working.

To demonstrate this function, i took the example which you already know .....

https://russian-dima.wixsite.com/meinewebsite/repeater-problem

These are all the comments given in this example here .....

https://russian-dima.wixsite.com/meinewebsite/autoupdate-picture

We want to find only unique comments of a unique user, using ---> .distinct()

Searching for comments of USER ---> 57da6cbf-baea-4248-8b1c-e7e82fcc01f8    --->

GO

01/19 - 01/23

Klicken Sie hier, um eigene Inhalte hinzuzufügen oder verbinden Sie Datenquellen aus Ihrer Kollektion.

01/19 - 01/23

Klicken Sie hier, um eigene Inhalte hinzuzufügen oder verbinden Sie Datenquellen aus Ihrer Kollektion.

01/19 - 01/23

Klicken Sie hier, um eigene Inhalte hinzuzufügen oder verbinden Sie Datenquellen aus Ihrer Kollektion.

Importing neccassery APIs......

import wixUsers from 'wix-users';

import wixData from 'wix-data';

Creating one GLOBAL-VARIABLE...

var userId;

First-Step: Getting the right USER-ID (happens emidiately when page is ready).

$w.onReady(function() {console.log("START")

    userId = wixUsers.currentUser.id

    console.log ("Your-User-ID : " + wixUsers.currentUser.id)

})

Step-II: Creating the DISTINCT-FUNCTION.......

function myFunction () {

    wixData.query("Comments2")

    .eq("_owner""57da6cbf-baea-4248-8b1c-e7e82fcc01f8")  //<----- here normaly the  --> userId ! ! ! ---> .eq("_owner", userId)

    .distinct("comment")

    .then((results) => {

        if (results.items.length > 0) {

            let items = results._items;

            let firstItem = items[0];

            let length = results.length;

                console.log(results)

                console.log("Data-Length : " + length)

                console.log(items)

 

            let myNewData = []         //<------------- creating new Array[] where to put in new data.

 

            for (var i = 0; i < length; i++) { 

                myNewData.push({"_id": ( i ).toString(), "comment": items[ ]})   //<------- creating new Object{} NECCASSERY ! ! ! .

            }

            console.log(myNewData)

 

            $w('#repeater1').data = myNewData;      //<------- Send DATA to ---> REPEATER (myNewData is now an OBJECT ! ! ! )

            

            $w("#repeater1").onItemReady(($item, itemData, index) => {

                $item("#ID").text = itemData._id;                             //<------- populating REPEATER-VALUES / DATA --> (generated-ID)

                $item("#COMMENT").text = itemData.comment;   //<------- populating REPEATER-VALUES / DATA --> ( comment )

            })

        }

        else {  }

    })

    .catch((error) => {

        let errorMsg = error.message;

        let code = error.code;

    });

}

Step-III: Connection a BUTTON with the DISTINCT-function, to controll it....

export function button1_click(event) { myFunction() }

Explanation

After running DESTINCT-function, you will get not the same RESULTS and also not the same STRUCTURE back, like for example, when using -----> .find( ).

DISTINCT gives you back, just the values of the current REFERENCE-COLUMN ! ! ! + The USER-ID ! ! ! 

RESULTS

2020-08-28 11_48_04-TEST-TEST-TEST _ Wix

<--- Gives back the user-ID ---> THIS WAS MISSING ! ! ! ! 

ITEMS

ATTENTION ! ! ! ---> NOT --> results.items !! wrong !!    ---->  results._items !!! right !!!

items.png
2020-08-28 11_54_37-TEST-TEST-TEST _ Wix

Our own created OBJECT with NO-DUBLICATES ! ---> let myNewData = [] 

for (var i = 0; i < length; i++) { 

         myNewData.push(  { "_id": ( i ).toString( ), "comment": items[ i ] }  )   //<------- creating new Object{} NECCASSERY ! ! ! .

}

ATTENTION ! ! ! ---> "_id" ---> has to be a STRING ! ! !

More INFORMATION here....

Comment-Box

CLOSE.png

Version-1.0

Under_Construction.png

Leave a comment. . .

Arrow.png

General-Settings

ON                 OFF

Show Text-Length

ON                 OFF

max. Text-Length

ON                 OFF

Show Key-Press

ON                 OFF

Show Key-Code

ON                 OFF

Show Total-Count

Character-limit

Load default settings
Save
mr-money-man 00:22:20

You can use also the CHAT if you want

 

8.8.2020
mr-money-man 00:22:01

Welcome back on my site ^^

8.8.2020
barbarabessals2 19:21:42

hello!

07/08/2020
mr-money-man 23:52:46

Hello Barbera ^^

7.8.2020
arthurvalatin 07:33:29

hello

04/08/2020
russian-dima 00:15:35

You can also set your own CHARACTER-LIMITATION in the SETTINGS but at moment 240
-characters are the max.

30.7.2020
arthurvalatin 07:13:39

hello!

30/07/2020
russian-dima 00:11:43

PRESS "TAB+ENTER" and you will see how it works without the button xD

30.7.2020
russian-dima 00:10:23

For example it is possible to send messages without to click everytime with the
mouse onto the button xDD

30.7.2020
russian-dima 00:09:45

You will find a lot of hidden intergrated stuff in my little comment/chat-tool ^
^

30.7.2020
arthurvalatin 07:09:33

Hello!

30/07/2020
russian-dima 00:08:44

Check it out! It almost works like a CHAT-BOX

30.7.2020
Page 1 of 1
Design
Settings
About
CLOSE.png
Leave a comment, or start a chat.

Post-Comment

- - -

Pressed-Key

- - -

Key-Code

Text-Length

- - -

max. Text-Length

- - -

Number of Comments

- - -

designed & developed by russian-dima

Write a comment
bottom of page