Skip to content
This repository has been archived by the owner on Mar 25, 2020. It is now read-only.

Adds support for storing FS.File references directly #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cfs-autoform-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ Hooks = {
// If it didn't fail, set the new ID as the property value in the doc,
// or push it into the array of IDs if it's a multiple files field.
else {
// Embed the FS.File instance if ejson is available
var fileVal = _.has(Package, 'cfs:ejson-file') ? fileObj : fileObj._id;

if (arrayFields[key]) {
CfsAutoForm.Util.deepFind(doc,key)[key].push(fileObj._id);
CfsAutoForm.Util.deepFind(doc,key)[key].push(fileVal);
} else {
//doc[key] = fileObj._id;
CfsAutoForm.Util.deepSet(doc,key,fileObj._id);
CfsAutoForm.Util.deepSet(doc,key,fileVal);
}
}

Expand Down