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.

Automatically create object-getter functions

See original GitHub issue

Currently, the shortest way to convert an object id into an object value is to do SELECT MyObject FILTER .id = some-uuid. Since converting ids to objects is a fairly common operation, it seems like a good idea to auto-generate getter functions like:

type SomeObject;

# auto-generated function
function SomeObject(id: uuid) -> optional SomeObject {}

Whether it should be a regular function or some function-like intrinsic is an open question.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
colinhackscommented, Jun 6, 2022

Once we commit to implementing Elvis’s original proposal, we can add this into the query builder:

const myDirectorId = 'xxxx-xxxx-xxxx';
  e.insert(e.Movie, {
    director: e.Director(myDirectorId),
  }).run(edgeClient)

Not sure what the latest status of this proposal is though.

0reactions
liron00commented, May 6, 2022

For inserting/updating links, consider:

  const myDirectorId = 'xxxx-xxxx-xxxx';
  e.insert(e.Movie, {
    director: e.select(e.Director, director => ({
      filter: e.op(director.id, '=', e.uuid(myDirectorId)),
    })
  }).run(edgeClient)

vs something like

  const myDirectorId = 'xxxx-xxxx-xxxx';
  e.insert(e.Movie, {
    director: e.selectById(e.Director, myDirectorId),
  }).run(edgeClient)

Because this kind of situation comes up often for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

Is there a way to automatically generate getters and setters in ...
Use Generate Getters and Setters from the Source menu or the context menu on a selected field or type, or a text selection...
Read more >
getter - JavaScript - MDN Web Docs - Mozilla
getter. The get syntax binds an object property to a function that will be called when that property is looked up.
Read more >
Automatically generate setters and getters - YouTube
This video demonstrates how to quickly and easily create your setters and getters methods using the built-in features in Eclipse (although ...
Read more >
JavaScript Getter and Setter (with Examples) - Programiz
In the above program, a getter method getName() is created to access the property of an object. ... Note: To create a getter...
Read more >
MultiGetSet.JS - Quickly generate getters and setters for ...
The "Observable" plugin let you know everytime some object change its value. ##Generating default Getters and Setters. var MyClass = function(){ var public ......
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