VTML
Github iconNPM icondownload
Tutorial
Getting startedHello worldMy first siteAdding a form
Documentation
VariablesLogicPagesSQLFormsChecksPortalsJavascriptEvent streams
Reference
v-withv-ifv-unlessv-for-eachv-portalv-jsonv-yamlv-markdownv-sqlv-nodejsv-dumpv-hint-portv-pagev-exposev-set-cookiev-includeformv-outputv-check-*v-catchv-tryv-set-statusv-redirectv-subscribev-notify
warning

VTML and vtml.org is in alpha and under active development. Use at your own risk

warning

VTML is in alpha. Use at own risk.

SQL

VTML provides the <v-sql> tag to conveniently query an SQL database.

In order to use the built-in sql integration VTML must be started with the DB_URL environment variable.

Currently supported databases are:

TypePrefixExample
PostgreSQLpg/postgres/postresqlpostgresql://user:pass@localhost:5432/mydb
SQLite3sqlite/sqlite3sqlite://database_file.sqlite
MySQL/MariaDBmysqlmysql://user:pass@localhost:3306/mydb

You can use <v-sql> like so:

<v-sql target=$things >
    select * from things;
</v-sql>

Variables are automatically bound but may need coercion in some cases:

<v-sql target=$things >
    select * from things where name = $.query.search::text;
</v-sql>

You can also use the <v-nodejs> interface directly.

The nodejs interface always uses ? as it's variable anchor.

<v-nodejs target=$from_node >
    return sql.query(`select * from things where name = ?`, [ $.query.search ])
</v-nodejs>

Using your own

Of course there's nothing stopping you from using a pre-existing nodejs database connector or ORM.

To do so just import the entrypoint using v-nodejs' import= attribute.

<v-nodejs target=$orm import="./my_super_orm" />

<v-nodejs target=$stuff >
    return $orm.search_stuff($.query.search)
</v-nodejs>