How to print out the data in collection on console?


import wixData from 'wix-data';

$w.onReady(function () {
 var x = wixData.get("jobApplication", "cf416325-713d-40b7-a98d-419252a7de2e");

    $w('#button1').onClick(() => {
        console.log("hey");
        console.log(x);
    });
})


As shown above, i created a website to allow customer to post their jobs ,i want to get the data(a specific row ) from the collection and print it out on console

Solution-1 (when using DATASET).

import wixData from 'wix-data';

var myDataset = //<---- put in here the ID of your DATASET! (NOT DATA-COLLECTION) !

$w.onReady( () => {
  $w("#myDataset").onReady( () => {
    $w("#myDataset").getItems(0, 1)
      .then( (result) => {
        let items = result.items;
        let totalCount = result.totalCount;
        let offset = result.offset;
        console.log(items)
        console.log(totalCount)
        console.log(offset)
        console.log("----------------")
        console.log(items[0].title)
        console.log(items[0]._id)
        console.log(items[0].id)
        console.log(items[0].startDate)
      } )
      .catch( (err) => {
        let errMsg = err.message;
        let errCode = err.code;
     });
  });
});

Solution-2 (when using DATA-COLLECTION-GET) NO-DATASET NEEDED!

import wixData from 'wix-data';

var myCollection = //<- put in here the NAME of your DATA-COLLECTION! (NOT DATA-COLLECTION) 

$w.onReady( () => {
   wixData.get("myCollection", "00001")
   .then( (results) => {
      let item = results; //see item below
      console.log(item)
   })
   .catch( (err) => {let errorMsg = err;});
})

Solution-3 (using DATA-COLLECTION-QUERY). NO-DATASET NEEDED!

import wixData from 'wix-data';

var myCollection = //<- put in here the NAME of your DATA-COLLECTION! (NOT DATA-COLLECTION) 

$w.onReady( () => {
   wixData.query("myCollection")
    .find()
    .then( (results) => {
      if(results.items.length > 0) {
        let firstItem = results.items[0]; //see item below
        let secondItem = results.items[1]
        console.log(firstItem)
        console.log(secondItem)
        //.... and so on .....
      } else {
        // handle case where no matching items found
      }
    })
    .catch( (err) => {
      let errorMsg = err;
  });
});