question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Object Literals Don't Work

See original GitHub issue

What 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:

  1. Create "Test1.md" with the following contents:
**Field**:: B

- [[Test Query]]
  1. Create "Test2.md" with the following contents:
**Field**:: A

- [[Test Query]]
  1. 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:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
iamrecursioncommented, Jul 21, 2022

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.

0reactions
AB1908commented, Jul 20, 2022

What’s the use case for something like this? I can only think of custom comparator functions.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found