Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7965701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:13:43+00:00 2026-06-04T06:13:43+00:00

Is there any way to fetch a collection by giving an initial model parameter

  • 0

Is there any way to fetch a collection by giving an initial model parameter to fetch().

To clear out: I have a model Human with attributes name (as a string) and numbers(array). I would like to find all the people in my database with given array of numbers. (Example: I have [123,342,4] in my array and for each number I would like to pull the people’s name).

I’ve created a Human collection giving the model is human. And when I fetch like this it causes no problem;

humanCollection.fetch({
            success:function(model,response){
                console.log(model.toJSON().length);
                var arr=model.toJSON();
                for(var i=0;i<arr.length;i++)
                    console.log(arr[i].humanName+" ");
                console.log("Success");
            },
            error:function(model,response){
                console.log(response);
                console.log("Failure");
            }
        });

I’m thinking of creating a dummy human object with no name and just numbers and later on passing the numbers to my php but .fetch() function doesn’t seem to work when I put a parameter to the beginning. Not even the code below works;

 humanCollection.fetch({},{
                success:function(model,response){
                    console.log(model.toJSON().length);
                    var arr=model.toJSON();
                    for(var i=0;i<arr.length;i++)
                        console.log(arr[i].humanName+" ");
                    console.log("Success");
                },
                error:function(model,response){
                    console.log(response);
                    console.log("Failure");
                }
            });

What could be the problem? And is it logical for me to create a dummy human model in order to retrieve a collection of humans with the given numbers. That was the only way I could think of transferring the specific required json data.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T06:13:44+00:00Added an answer on June 4, 2026 at 6:13 am

    I think you are messing up things.

    As I understood the numbers are the Human.ids you want to fetch.

    If this is correct these numbers have not any meaning to be part the the Human model. I rather will move them to the Collection.

    You have to prepare the Collection to send a filter param in the URL of the fetch that informs to the server layer which Humans the Collection wants to fetch.

    Also you have to prepare the server layer to be able to process the filter param with the ids of the Humans you want the server responses with.

    So, in the Backbone Collection we can play with the data option of the fetch() method like this:

    humanCollection.fetch({ data: { ids: [123, 342, 4] } });
    

    The server will have to parse the ids param and return only the requested Humans.

    Then in your Collection you will only have your selected Humans and you will can ask them for name or whatever.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any way to fetch uncommited changes I left when I checkout out
Is there any way that each child of a collection will be loaded individually
Is there any efficient way to fetch texture data in a random way? That
Is there any way, with the current tools, to fetch the posts from the
Is there any way to change the BackColor of the border of a panel
Is there any way I can run class files (i.e. with main as the
Is there any way to view the reduction steps in haskell, i.e trace the
Is there any way to change the icon of an application after it is
Is there any way to validate the contents of a CEdit box without subclassing?
Is there any way that I can create a new delegate type based on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.