Skip to content

Extending Query via JavaScript #6

@dominicbarnes

Description

@dominicbarnes

I was wanting to extend the Query prototype to allow for some custom query chain helpers. I was really hoping to do this via JavaScript, as I'm not a C programmer.

I've got a hold of the Query prototype, and I've seen an example of extending Query, but the example was not related to SQL generation at all, which is the most practical way to extend Query. I'm working on a more administrative API, so I was wanting to add methods for USE, CREATE, SHOW, etc.

For example: (here is a wrapper for USE my_database;)

Query.prototype.use = function (database) {
    this.sql("USE " + this.db.name(database));
    return this;
};
  • I am using this.sql() as a setter (this idea is probably not going to work, I'm not really sure how the C code is handling SQL generation, especially if an SQL command requires several commands that could come in any order)
  • I would like some reference to the Database object within the Query object, so I can call things like name, escape, etc.

If I am just completely missing the boat here, please let me know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions