This commit is contained in:
Hion-V 2022-10-07 17:22:05 +02:00
parent edc1ea081f
commit 6962885582
4 changed files with 20 additions and 16 deletions

View File

@ -4,6 +4,7 @@
-lib tink_json -lib tink_json
-lib tink_sql -lib tink_sql
-lib hxnodejs -lib hxnodejs
-D await_catch_none
-cp src -cp src
--main Server --main Server
-js build/out.js -js build/out.js

View File

@ -63,10 +63,10 @@ class Root {
public function user() public function user()
return new User(); return new User();
@:sub('/projects') // @:sub('/projects')
@:produces('application/json') // @:produces('application/json')
public function projects() // public function projects()
return new Projects(); // return new Projects();
@:get('/hello') @:get('/hello')
@:produces('application/json') @:produces('application/json')

View File

@ -5,6 +5,8 @@ import Utils;
import db.Db; import db.Db;
import model.MUser; import model.MUser;
using tink.CoreApi;
class User{ class User{
public function new() {} public function new() {}
@ -20,24 +22,25 @@ class User{
} }
@:get('/registerDummyUser') @:get('/registerDummyUser')
@:produces('text/plain') @:produces('application/json')
public function registerdummyuser(){ public function registerdummyuser(){
//@await var db = new Db('daba2', driver); //@await var db = new Db('daba2', driver);
db.MUser.create().next(function(){ // var failed:tink.core.Next<tink.sql.Id<model.MUser>> = null
db.MUser.insertOne({ @await var result = db.MUser.create().next(
return db.MUser.insertOne({
id: cast null, id: cast null,
name: 'Alice', name: 'Alice',
email: 'alice@example.com', email: 'alice@example.com',
password: 'jew' password: 'jew'
}).next(function(){ }));
db.MUser.select({name: MUser.name, email: MUser.email}).where(MUser.email == 'alice@example.com').first().next(function(row) { result.handle(function(outcome) {
trace(row.name); switch outcome {
// return "$row"; case Success(data): return data;
}); case Failure(e):
}); trace("failure: "+e);
return null;
}
}); });
return "success";
// @await var three = ; // @await var three = ;
// trace(@await one); // trace(@await one);
// trace(@await two); // trace(@await two);

View File

@ -13,5 +13,5 @@ typedef Db = tink.sql.Database<Def>;
@:tables(MUser) @:tables(MUser)
interface Def extends tink.sql.DatabaseDefinition { interface Def extends tink.sql.DatabaseDefinition {
//@:procedure var func:Int->{x:Int, point:tink.s2d.Point}; //@:procedure var func:Int->{x:Int, point:tink.s2d.Point};
//@:table('user') var UserAlias:User; @:table('user') var UserAlias:MUser;
} }