Comments (6)
On the other hand, what I think we could do is to have a way to return a MySQL object which has a number of fields, each of them being a function (e.g. field findOne
being a function for finding a single row in a table etc.) and then run mysql.findOne()
.
Please note that here we use dot instead of the colon. In AskScript we used colon for the "method" syntax sugar and method chaining, but dot for accessing properties (see e.g. this sample .ask file: https://github.com/CatchTheTornado/askql/blob/master/src/askscript/__tests__/08-objects-records/objects-14-key_access.ask )
from askql.
... the simplest possible solution could be to extend the run()
method on vm
to let the officially registered resources return methods or return sub-resources (chaining) etc. we're not talking about the OOP methods - however this could potentially be a great solution too
from askql.
@pkarw , the issue I see here is that currently code like mysql:findOne()
is just a syntactic sugar over findOne(mysql)
, which means that regardless what kind of variable mysql
is, the very same findOne()
function will be called.
The translation is not done in run()
in vm
, which is called when executing the parsed program, but much earlier - when parsing the AskScript source code into AST.
from askql.
This way we could have:
// mysql - a resource that has several fields with functions, e.g. connect
conn = mysql.connect('host', 'user', 'pass')
conn.useDb('dbname')
row = conn.findOne('text to search for')
from askql.
@czerwinskilukasz1 good point. I think it's a great way to go for this FR; it's somewhat clarifying the #580 as well (I mean the "dot" notation could be used to have both #579 and #580 up)
from askql.
Blocked by #589
from askql.
Related Issues (20)
- Enable string property names HOT 1
- A DB example
- `npm run build` fails on Windows (`mv` command is unknown)
- Syntax for using a resource can be simplified
- Refactor let HOT 3
- Command line CLI should allow (but not require) wrapping code in ask {} HOT 1
- Allow sharing of playground
- Refactor: extract common logic, checking if a reserved keyword is used, from let, const and assign resources to avoid code duplication. HOT 1
- Frontend-driven database access aka. "The Ultimate Endpoint" HOT 7
- Add JsonPath support HOT 3
- Add Lambda/serverless function as the resources HOT 2
- Let developers to call JS methods on limited JS objects HOT 9
- Add Secrets management feature HOT 2
- Access control and session management HOT 1
- Add stored procedures/persited/hash queries HOT 1
- Add HTTP GET variables access to AskScript
- TypeScript SDK HOT 1
- Add React Context and/or hooks for querying AskQL endpoints
- Unable to call object properties that are functions HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from askql.