Giter VIP home page Giter VIP logo

Comments (6)

czerwinskilukasz1 avatar czerwinskilukasz1 commented on August 16, 2024 1

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.

pkarw avatar pkarw commented on August 16, 2024

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

czerwinskilukasz1 avatar czerwinskilukasz1 commented on August 16, 2024

@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.

czerwinskilukasz1 avatar czerwinskilukasz1 commented on August 16, 2024

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.

pkarw avatar pkarw commented on August 16, 2024

@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.

mhagmajer avatar mhagmajer commented on August 16, 2024

Blocked by #589

from askql.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.