[Bug] Object Literals Don't Work
See original GitHub issueWhat happened?
There is no context in which I can get an object literal to work without throwing an error as follows:
Cannot read property 'successful' of undefined
Reproduce as folllows:
- Create
"Test1.md"
with the following contents:
**Field**:: B
- [[Test Query]]
- Create
"Test2.md"
with the following contents:
**Field**:: A
- [[Test Query]]
- Create
"Test Query.md"
with the following contents:
```dataview
table without id
file.name as "Name",
Field,
((x) => { A: 1, B: 2 }[x])(Field) as "Processed"
from [[#]]
where Field
sort Field asc
```
I would expect to be able to index into the object literal here (much like one can in JS), but it seems like the literal itself can’t even be created.
Note that I may be filing a desktop bug report but this happens regardless of platform.
DQL
table without id
file.name as "Name",
Field,
((x) => { A: 1, B: 2 }[x])(Field) as "Processed"
from [[#]]
where Field
sort Field asc
JS
No response
Dataview Version
0.4.26
Obsidian Version
0.14.2
OS
MacOS
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
JavaScript object literal not working [duplicate] - Stack Overflow
When you use () to surround the {} you are creating an expression which is how the object gets evaluated. However, you can...
Read more >Object literals / JSON typed directly in web console do not ...
Typing an object literal is most useful when debugging/'trying stuff', eg. I have a function that works as an enumerator and I want...
Read more >JS autocomplete doesn't work for object literal shorthands
Suppose there are variables in the current context (be it local or global); Create an object literal and try to use a variable...
Read more >499864 - Console: Handle object literals - chromium - Monorail
The console should be smart enough to realise that the user meant to inspect an object literal. This isn't a bug report, it's...
Read more >How to use Object Literals in JavaScript to write complex ...
When there are multiple conditions, I find object literals to be the most readable way of structuring code. Let's have a look at...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Custom comparators were indeed the original motivation for filing this one! Putting it as a table column was just by way of demonstration as indeed I had wanted it for custom comparators where chains of conditionals quickly became unwieldy.
What’s the use case for something like this? I can only think of custom comparator functions.