Editor upload many returns all files in database.

Editor upload many returns all files in database.

naspersgaspnaspersgasp Posts: 53Questions: 14Answers: 1

Hi,

Good day.

I've successfully configured upload many files. When I inspect the JSON returned from the server, all the details of files contained in the files table are returned as well.

Even though none of the files are used in the list displayed, as I have server side processing enabled. I would imagine the list to only be what is displayed, or no list at all. As the file info relating to a row is in the data portion as well. Is there an option I am missing?

I'm using the example code so you can test it easily. It is the controllers/upload-many.js and examples/upload-many.html in the Editor-NodeJS-1.7.4 download.

I saw a similar ticket about this somewhere, but I just can't seem to find it. So sorry if I'm opening a duplicate. Thanks.

Regards.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Hi,

    Yes, this I fear is a limit of a short cut that Editor takes. It assumes (at the moment) that the file meta table is just going to be for files, so it grabs the whole lot for the client-side to then be able to get the information it needs to display images (rather than attempting to limit the selected rows to just those needed for the data set).

    Is there a field in the table that you can use to check a condition to see if the row in the db contains image meta data? If so, use the Upload->where() method to restrict the data set to that.

    Allan

  • naspersgaspnaspersgasp Posts: 53Questions: 14Answers: 1

    Hi.

    Thanks for explaining. Currently I'm using the same setup as the upload-many example.

    Tables:

    Users -> columns [id, name...]
    Files -> columns [id, filename,...]
    UserFiles -> columns [user_id, file_id]
    

    Could you explain how I would go about using the Upload->where()? I'm guessing I would add a user_id column to the Files table and set the user_id so I can use it in the where clause? Am I on the right track? And if so how would I get the user_id when uploading into the Files table? (Lots of question marks:)

    Regards.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    Do you have anything in the Files table that uniquely identifies it as being part of the user files? The Upload class doesn't currently do a join to allow it to check what is in UserFiles I'm afraid. That is something that should be available in 1.8.

    Allan

  • naspersgaspnaspersgasp Posts: 53Questions: 14Answers: 1

    Hi,

    Good day.

    I can add a user_id column to the Files table. The question was if I do, how would I set the user_id in the Files table on upload? Not to sure how, as the server side handles that auto-magically.

    Regards.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin

    I was thinking more of a type field which could be used to do a where type = 'userFile'. That would restrict the SELECT to just the files for the user / file link. But it still wouldn't limit it to only the files needed for the current DataTable view I'm afraid.

    Allan

  • naspersgaspnaspersgasp Posts: 53Questions: 14Answers: 1

    Hi,

    Not quite what I meant. If I have server side set as true. And it returns a page where none of the records have files attached, then the entire files table should not be returned.

    I guess I'm looking to modify the bit where you do a:

    select * from files;" 
    

    to be:

    select * from files where user_id in (list_of_results_for_page);" 
    

    The only reason why I need this is because I'm dealing with 30k files. And returning the entire files table defeats having server side enabled.

    I'll try and step through the code and see if I can find a workaround.

    Regards.

  • allanallan Posts: 63,680Questions: 1Answers: 10,498 Site admin
    Answer ✓

    I see what you mean - thanks for the clarification and apologies for my misunderstanding.

    Yes, that is something that Editor's server-side libraries do not currently support I'm afraid. That is the feature that should come in 1.8 that I mentioned above.

    Allan

  • naspersgaspnaspersgasp Posts: 53Questions: 14Answers: 1

    Hi,

    Good day.

    Thanks man, looking forward to it. Will test with a couple of images just to get POC done.

    Regards.

This discussion has been closed.