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.

Can we get auto-completion for $set method?

See original GitHub issue

Pretty much like how we get the current auto complete when using .where() method.

image

Currently, we get nothing.

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

2reactions
koskimascommented, Mar 18, 2020

There’s no intended way of setting properties. You can do it however you want. The $set method works, you just don’t get auto completion currently. We could in theory define the $set method like this

$set(obj: PartialModelObject<this>)

Where PartialModelObject is like Partial, but it also removes methods. But that would only allow a subset of the defined properties to be set. Objection allows you to set any properties for historical reasons.

Objection was developed without typescript, and adding typescript typings afterwards like this is always a compromise, and some things don’t work so well.

You can easily create your own helper like:

class BaseModel extends Model {
  set(obj: PartialModelObject<this>): this {
    return this.$set(obj)
  }
}

And then just inherit your models from BaseModel instead of Model.

0reactions
cerino-ligutomcommented, Mar 18, 2020

Nice, this works great for our use case, thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Autocomplete in eclipse skipping getters and setters
No, there's no functionality like that in Eclipse, as far as I know. However, Eclipse does support CamelCase searches in most places, ...
Read more >
HTML attribute: autocomplete - MDN Web Docs
The HTML autocomplete attribute lets web developers specify what if any permission the user agent has to provide automated assistance in ...
Read more >
IntelliSense in Visual Studio Code
If you continue typing characters, the list of members (variables, methods, etc.) is filtered to only include members containing your typed characters.
Read more >
Auto-completion - Notepad++ User Manual
You can use arrow keys (or the mouse) to navigate through the entries in the popup; hitting the completion key or double-clicking on...
Read more >
Place Autocomplete | Places API - Google Developers
This section describes best practices to help you make the most of the Place Autocomplete service. Here are some general guidelines: The quickest...
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