vlang / vlang/website

Initializing an new vweb project crashes

Open
#239 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
HTML
Stars
67
Forks
101
PR merge metrics
No merged PRs in 30d

Description

Following the first instruction to ininitalize a VWeb project

v new myproject web
cd myproject
v src

leads into the following error:

v src/      
src/auth_services.v:28:22: error: unknown function: databases.create_db_connection 
   26 | 
   27 | fn (mut app App) service_auth(username string, password string) !string {
   28 |     mut db := databases.create_db_connection() or {
      |                         ~~~~~~~~~~~~~~~~~~~~~~
   29 |         eprintln(err)
   30 |         panic(err)
src/auth_services.v:34:6: error: cannot call a method using an invalid expression
   32 | 
   33 |     defer {
   34 |         db.close() or { panic(err) }
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~
   35 |     }
   36 |
src/main.v:20:22: error: unknown function: databases.create_db_connection 
   18 | 
   19 | fn main() {
   20 |     mut db := databases.create_db_connection() or { panic(err) }
      |                         ~~~~~~~~~~~~~~~~~~~~~~
   21 | 
   22 |     sql db {
src/main.v:26:5: error: cannot call a method using an invalid expression
   24 |     } or { panic('error on create table: ${err}') }
   25 | 
   26 |     db.close() or { panic(err) }
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~
   27 | 
   28 |     mut app := &App{}
src/product_service.v:6:22: error: unknown function: databases.create_db_connection 
    4 | 
    5 | fn (mut app App) service_add_product(product_name string, user_id int) ! {
    6 |     mut db := databases.create_db_connection()!
      |                         ~~~~~~~~~~~~~~~~~~~~~~
    7 | 
    8 |     defer {
src/product_service.v:9:6: error: cannot call a method using an invalid expression
    7 | 
    8 |     defer {
    9 |         db.close() or { panic(err) }
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~
   10 |     }
   11 |
src/product_service.v:29:22: error: unknown function: databases.create_db_connection 
   27 | 
   28 | fn (mut app App) service_get_all_products_from(user_id int) ?[]Product {
   29 |     mut db := databases.create_db_connection() or {
      |                         ~~~~~~~~~~~~~~~~~~~~~~
   30 |         println(err)
   31 |         return err
src/product_service.v:35:6: error: cannot call a method using an invalid expression
   33 | 
   34 |     defer {
   35 |         db.close() or { panic(err) }
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~
   36 |     }
   37 |
src/user_services.v:7:22: error: unknown function: databases.create_db_connection 
    5 | 
    6 | fn (mut app App) service_add_user(username string, password string) ! {
    7 |     mut db := databases.create_db_connection()!
      |                         ~~~~~~~~~~~~~~~~~~~~~~
    8 | 
    9 |     defer {
src/user_services.v:10:6: error: cannot call a method using an invalid expression
    8 | 
    9 |     defer {
   10 |         db.close() or { panic(err) }
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~
   11 |     }
   12 |
src/user_services.v:40:6: error: cannot call a method using an invalid expression
   38 | 
   39 |     defer {
   40 |         db.close() or { panic(err) }
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~
   41 |     }
   42 |
src/user_services.v:51:22: error: unknown function: databases.create_db_connection 
   49 | 
   50 | fn (mut app App) service_get_user(id int) ?User {
   51 |     mut db := databases.create_db_connection() or {
      |                         ~~~~~~~~~~~~~~~~~~~~~~
   52 |         println(err)
   53 |         return err
src/user_services.v:57:6: error: cannot call a method using an invalid expression
   55 | 
   56 |     defer {
   57 |         db.close() or { panic(err) }
      |            ~~~~~~~~~~~~~~~~~~~~~~~~~
   58 |     }
   59 |

However running

v new myproject
cd myproject

and copy pasting the example from the home page works as expected.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the VWeb documentation page linked in the issue and reproduce the commands v new myproject web, cd myproject, and v src. Compare the generated src/auth_services.v, src/main.v, src/product_service.v, and src/user_services.v with the working homepage example. Done means the documented initialization command compiles without the missing databases.create_db_connection errors.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.