In this test it's well exemplified how to do a file upload with Hook
You can set a input[type=file] or a blob to a collection field. It will store the value as a file, and retrieve a URL to you.
@danray0424 considering you have a posts
collection which belongs_to authors
, you could create posts linked to authors like this:
hook.collection('posts').create({
author_id: 1, // By default, foreign keys are always `{parent_collection_name}_id`
name: "Post name"
})
Now, when you query with join (hook.collection('posts').join('author')
) it would return the author object with _id=1
in the response.
Hope this helps, please let me know if you have any other question!
belongs_to
, and both of those have an _id field. Sorry about that. So I create a parent, read its ID, and use that in the create statements for its children. Can do.
belongs_to
relationship defined on books
and a has_many
defined on authors
. I've created a gist to better demonstrate here: https://gist.github.com/endel/36c0d82a02cc2e16ecd1#file-hook-console