kitchen-site icon indicating copy to clipboard operation
kitchen-site copied to clipboard

[enhancement] make "Collection" field optional in query

Open Fr33maan opened this issue 9 years ago • 12 comments

Hi,

My problem is if I want to create cutom publish, I need to edit them in the JSON editor rather than left the Collection field blank.

Fr33maan avatar Jul 08 '16 12:07 Fr33maan

It is not even possible, kitchen complains that the collection does not exists if I do that and stop generating.

@perak could you think about making this optional even for generation ?

Fr33maan avatar Jul 13 '16 22:07 Fr33maan

Makes sense! I'll do it.

On Thursday, 14 July 2016, libre [email protected] wrote:

It is not even possible, kitchen complains that the collection does not exists if I do that and stop generating.

@perak https://github.com/perak could you think about making this optional even for generation ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/perak/kitchen-site/issues/320#issuecomment-232508927, or mute the thread https://github.com/notifications/unsubscribe/AFXrXkrZoxzLeXcBG3OQ1z8Gidngo5zZks5qVWqYgaJpZM4JH_Jr .

perak avatar Jul 13 '16 22:07 perak

@perak for now I'll use a special collection named "CustomQueries" and then overwrite the publish file in server/publish after generator ran.

Fr33maan avatar Jul 13 '16 22:07 Fr33maan

Hum... what if you provide publication via "copy_files"?

perak avatar Jul 13 '16 22:07 perak

Ha my solution is not even working because the component tries to find a cursor in CustomQueries collection which is empty because it does not exists.

What do you mean ? If I had another publish file with the publication ? Meteor just ignore the second one in the case. Maybe if I had it before the generated file it could work. I will try it now.

Fr33maan avatar Jul 13 '16 23:07 Fr33maan

"copy_files" executes last - after everything is generated, so you can overwrite original publication.

perak avatar Jul 13 '16 23:07 perak

Ok, if I name a query "todo_models_with_percent_active" linked to the "TodoModels" collection, I can copy a file called 0_todo_models_with_percent_active.js in server/publish with the custom publication inside.

The publication generated in the todo_models.js file will be ignored by meteor and the custom will be used.

Fr33maan avatar Jul 13 '16 23:07 Fr33maan

Ho didn't know that exists. Maybe cleaner than my solution :p

Fr33maan avatar Jul 13 '16 23:07 Fr33maan

This is still a hack... so requires better more universal and long-term solution.

perak avatar Jul 13 '16 23:07 perak

Yes, it is listed in the "hacks" section of my readme :)

Fr33maan avatar Jul 13 '16 23:07 Fr33maan

What kind of hackers we will be if we don't make hacks? :)

perak avatar Jul 13 '16 23:07 perak

right !

Fr33maan avatar Jul 13 '16 23:07 Fr33maan