Primary and Embedded Updates
TIL how to update embedded documents at the same time as parent documents.
This makes sense when you look at the
data._source
of the Actor and see how the items are stored there.C
Calego•927d ago
Data structure for example (5e actors)
C
Calego•927d ago
Since
items
is expected to be an embedded collection, the .update
method does the dirty work of exploding out the array as individual updates automatically.
Setting an array in the update
method for data that isn't expected to be an embedded collection would simply override the array entirely.
Interestingly, this works just fine if you have multiple objects in the updateData items
array with the same _id
. Presumably each one is operated on sequentially.
Resulted in an item named Arrow +2.2
E
Ethck•927d ago
Would it be possible to update a parent but include a new child item as well? I'm trying to limit the number of round trips to the server so if I can condense it that'd be
C
Calego•927d ago
Pretty sure definitely yes
yeah!
So
E
Ethck•927d ago
So (based off of memory) if I call an update with data that does NOT contain an ID it usually fails. How do you get around that?
C
Calego•927d ago
if the
_id
is there, it's an update operation. but if not it's a createE
Ethck•927d ago
ooh
Sweet!
C
Calego•927d ago
So you've gotta have all the right fields present
for items, that's
name
and type
E
Ethck•927d ago
That's what I was hoping.
C
Calego•927d ago
E
Ethck•927d ago
Yeah, I just remember running into issues with update(s) and not having an
_id
lol.C
Calego•927d ago
E
Ethck•927d ago
So perfect! Thanks @calego
LTL
Leo The League Lion•927d ago
@ethck gave LeaguePoints™ to @calego (#1 • 1258)
C
Calego•927d ago
NICE
documents rock
E
Ethck•927d ago
definitely helps in situations like this.
C
Calego•927d ago
Ohhh ok, interesting, found this snippet:
so you could construct the ephemeral
Item
beforehand to more easily interact with its data, then toObject
it and push that into the update dataE
Ethck•927d ago
What's the difference between doing
CONFIG.Item.documentClass
and just Item
? Aren't they the same (usually)?C
Calego•927d ago
CONFIG.Item.documentClass
would get you the system's item class, e.g. Item5e
E
Ethck•927d ago
Ah, and I assume that's probably the more preferred route, good to know!
C
Calego•927d ago
its more bulletproof yeah, in case a system does something particular about its created items, this would run the right constructor and suchforth and so on, instead of only running the Core ones.
E
Ethck•927d ago
Makes sense.
M
Mana•926d ago
BTW, this combined update is dangerous with unlinked tokens.
E
Ethck•926d ago
How so?
M
Mana•926d ago
Updating single small piece of an item with it causes it to replace the entire item list with what's in the update. So you end up destroying all items and their data that you didn't include.
The joys of unlinked tokens, you know.
Want results from more Discord servers?
More Postscompendium errors upgrading to v9hmm im not entirely sure how this will work though.. because I did just a quick smell test to my modBlind Chat MessagesAnyone have good examples of creating a chat message that should only be visible to a connected GM, compendium shennaneginsTIL about `CompendiumContent.getDocuments` taking nedb queries.
```
game.packs.get('dnd5e.heroes').gwith just a parent class and the class name, is there a way to instantiate a new class?JamesB and @veterini have a question for y'all in #coc7-dev
https://discord.com/channels/7323252527More Hooks 5ehttps://github.com/ElfFriend-DnD/foundryvtt-more-hooks-5e
I'm going to try to use this library to hacreateEmbeddedDocuments issueI'm going to throw my code in a thread so I don't clutter this channel up with a wall of textBase Item@otigon it occurs to me that the new `baseItem` property on weapons and such is probably of interestCompendium loadinghmm ghost, I added some console.time tags here and there to measure the difference between loading oSkill and Ability bonusesA massive enhancement of Skills and Ability Checks/Saves allows them to be individually affected by 150 Sheet Changes@sdenec @lordzeel
Sheet Changes required:
- New Cog-menu for Ability Scores and Skills to support neDocumentData shennaneginsTIL: It is possible to `update` an Actor or Item's `data.data` with arbitrary information that isn'tflag shenanneginsTIL you can set the `flags` key on a document to whatever you want to (e.g. a string). This is a surraaeAfter some discussion yesterday in #active-effects , I decided to try to create a system-agnostic modevMode json changed warningI checked the module repo and I honestly can't figure out where I would plug in my code.
I'd be guesS3 File Picker SettingsCan someone with an S3 configuration give me a test of the FilePicker settings api and tell me if a item preCreate@sol.folango @mrprimate (pinging you two in particular because you do import stuff involving existinItem Macro Compendium WorkflowOkay, here's a long one that's a bit of a doozy. I'm looking at setting up some sort of tooling/workItem Specific Crit DetailsOh that critical hit thing is gonna hit MRE too isn't it... hrm...1.5.x 72%@dnd5e No action required (but suggested 🙂 )
The 1.5.0 milestone is ~72% complete. It has a due daV9 Tabs IssueIf you never figured this out, here's why this happened:
A small change in `Tabs` during v9 causes s