How to Get an Item From a Data Collection with WiX Code | WiX Data API - .get() Method | Velo

Поделиться
HTML-код
  • Опубликовано: 26 окт 2022
  • In this series I walk you through the long await WiX Data API!
    The WiX Data API allows you to interact with data collections using code (Velo). With just a few lines of code you can get, add, remove or update items in your collection. You can also do more complex things such as querying a collection based on a certain field - value pair, using hooks to take action before or after a collection is changed and more!
    In this video I talk about the .get() method with lets you retrieve an item from a collection using the item id.
    See the full documentation here:
    www.wix.com/velo/reference/wi...
    New to Velo? Try my new Velo for Beginners course:
    www.udemy.com/course/velo-for...
    Have an idea for a video? suggest it here:
    www.thewixwiz.com/youtube
    Have questions? Join the discussion:
    www.thewixwiz.com/forum
    Want to have joint coding session? Book one now:
    www.thewixwiz.com/book-online
    Have questions? Need some magic done on your website ASAP?
    www.thewixwiz.com/contact-us
    Follow along on Twitter @thewixwiz
    Facebook page: / thewixwiz
    Facebook community: / thewixwiz

Комментарии • 37

  • @thewixwiz
    @thewixwiz  8 месяцев назад

    👋👋New to Velo? Check out my new Beginners course now on Udemy! ➡➡ www.udemy.com/course/velo-for-beginners/

  • @walkthroughonthego2476
    @walkthroughonthego2476 9 месяцев назад

    would it be possible to do the same? but instead of using the id that wix provides, i create a separate field and make it primary called "userID"?

    • @thewixwiz
      @thewixwiz  9 месяцев назад

      With .get() you can only use the WiX ID. To use any other field take a look at the .query() tutorial.

    • @walkthroughonthego2476
      @walkthroughonthego2476 9 месяцев назад

      @@thewixwiz understood! thanks a ton for your quick reply! subscribed!

  • @RudeRumourPS5
    @RudeRumourPS5 Год назад +1

    how can i get the ID of an item to vary depending on the item displayed on the page (dynamic page)?

    • @thewixwiz
      @thewixwiz  Год назад +1

      You can use $w("#dynamicDataset").getCurrentItem()

    • @RudeRumourPS5
      @RudeRumourPS5 Год назад

      @@thewixwiz i want to use the values in database collection for the values in wixpay createpaymentforproduct function. i tried this snippet but it doesn’t all $w in as a value in back end jsw file any ideas how to get this to work?

  • @ifampk
    @ifampk 10 месяцев назад

    hi, i have one question how can i get data with someother field instead of _id?

    • @thewixwiz
      @thewixwiz  10 месяцев назад

      For that you will need to use WiX data query.

  • @joannkol5087
    @joannkol5087 3 месяца назад

    Hi tested this, and noticed it works for items in the collection are the "visible" but it produces a null value when the item is "hidden." the collection I'm testing this with is tied to dynamic pages. Is there an adjustment we can make to include hidden items in the function?

    • @thewixwiz
      @thewixwiz  3 месяца назад +1

      Hi, one option would be to use a boolean field to control if items are hidden on your site or not and employ custom logic where you are querying and displaying collection items.

    • @joannkol5087
      @joannkol5087 3 месяца назад

      @@thewixwiz how would you employ custom logic with a get or query function?

  • @asega27
    @asega27 3 месяца назад

    How can I look for someone for lets say a certain name in the CMS like if name is the same blank

    • @thewixwiz
      @thewixwiz  3 месяца назад

      What do you mean "the same blank"?

  • @SennaCrow
    @SennaCrow 10 месяцев назад

    I've been trying to connect a dropdown to a collection only through wix code so I can change the default value on click. How do I do that...? I've been searching forever for this solution. Every time I cross someone who has ".option" or ".setOption" in their code, mine won't take that. Losing my mind here. It's such a simple thing, but.......I can't figure it out.
    :(

    • @thewixwiz
      @thewixwiz  10 месяцев назад

      Have you checked out the API documentation?
      www.wix.com/velo/reference/$w/dropdown/options

  • @FubuDon
    @FubuDon Год назад

    I'm getting a null value when trying to search using email. How can I correct this?

    • @thewixwiz
      @thewixwiz  Год назад

      You may be looking for WiX data Query.

    • @FubuDon
      @FubuDon Год назад

      @@thewixwiz thanks

  • @arkthespark
    @arkthespark Год назад

    I want to get products collection created by stores app of wix.

    • @thewixwiz
      @thewixwiz  Год назад

      support.wix.com/en/article/velo-wix-stores-products-collection-fields

  • @RaymondWarren-qw1sq
    @RaymondWarren-qw1sq Год назад

    Can't get this to work. There are missing steps to setting up the page which the vide shows as set up with a name field but does not explain. Is it a dynamic page? Does the collection need to be connected? How?....

    • @thewixwiz
      @thewixwiz  Год назад +1

      Hi there, the video assumes you have basic knowledge of WiX elements and collections. The page in this demonstration is a regular page and the interaction with the collection is done using code.

    • @emmanuelyevu7459
      @emmanuelyevu7459 Год назад

      @@thewixwiz sorry to say this...but it doesnt seem to work...has wix made any update conflicting this?

    • @emmanuelyevu7459
      @emmanuelyevu7459 Год назад +1

      @@thewixwiz im sooo sorry wix wiz...i just figured out it really works...thankssss soooo sooo much

    • @emmanuelyevu7459
      @emmanuelyevu7459 Год назад +1

      The code only runs in preview mode but doesnt run on the actual website....can i get some tips on this...what actually is wrong...please help sir

    • @thewixwiz
      @thewixwiz  Год назад +1

      @@emmanuelyevu7459 Please post your question to the forum along with code snippets, error messages, and screenshots if necessary. eitanwaxman.com/forum

  • @slypaul911
    @slypaul911 Год назад

    hi how do Display a Different image every hour from a Collection data base on my home page which is a regular page not a dynamic page ive set up collection with time in the field and connected it to data set but nothing seems to happen please help me my friend as something i thought would be really easy to do is driving me mad

    • @thewixwiz
      @thewixwiz  Год назад

      Hi, thanks for your question. You are welcome to join the livestream today and ask about it
      ruclips.net/user/live4uPX9GB3n7c?feature=share

  • @NODNyNy
    @NODNyNy 8 дней назад

    can you please do a post request to create a member using only email?

    • @thewixwiz
      @thewixwiz  4 дня назад

      You could expose an endpoint using http-functions or look into the REST APIs if you're building an app for Wix.

  • @TonkaJahari
    @TonkaJahari 16 часов назад

    This code didnt work for me. I'm not sure why. I am trying to get a text box to display a specific item's title

    • @TonkaJahari
      @TonkaJahari 16 часов назад

      Got this code bacl: Oj-vej! This event is not supported by logger Failed to evaluate expression: Error: Syntax error. Unexpected whitespace near: myCollection = "Adaptations
      const myId = "7ad44c44-e1b6-4ac6-9ea6-3de3f8b929de"

  • @PoojaSinha-ir3rw
    @PoojaSinha-ir3rw Год назад

    What language name called use in wix

    • @thewixwiz
      @thewixwiz  Год назад

      Not sure I understand 😅