kk
This commit is contained in:
parent
edc1ea081f
commit
6962885582
@ -4,6 +4,7 @@
|
||||
-lib tink_json
|
||||
-lib tink_sql
|
||||
-lib hxnodejs
|
||||
-D await_catch_none
|
||||
-cp src
|
||||
--main Server
|
||||
-js build/out.js
|
||||
|
||||
@ -63,10 +63,10 @@ class Root {
|
||||
public function user()
|
||||
return new User();
|
||||
|
||||
@:sub('/projects')
|
||||
@:produces('application/json')
|
||||
public function projects()
|
||||
return new Projects();
|
||||
// @:sub('/projects')
|
||||
// @:produces('application/json')
|
||||
// public function projects()
|
||||
// return new Projects();
|
||||
|
||||
@:get('/hello')
|
||||
@:produces('application/json')
|
||||
|
||||
@ -5,6 +5,8 @@ import Utils;
|
||||
import db.Db;
|
||||
import model.MUser;
|
||||
|
||||
using tink.CoreApi;
|
||||
|
||||
|
||||
class User{
|
||||
public function new() {}
|
||||
@ -20,24 +22,25 @@ class User{
|
||||
}
|
||||
|
||||
@:get('/registerDummyUser')
|
||||
@:produces('text/plain')
|
||||
@:produces('application/json')
|
||||
public function registerdummyuser(){
|
||||
|
||||
//@await var db = new Db('daba2', driver);
|
||||
db.MUser.create().next(function(){
|
||||
db.MUser.insertOne({
|
||||
// var failed:tink.core.Next<tink.sql.Id<model.MUser>> = null
|
||||
@await var result = db.MUser.create().next(
|
||||
return db.MUser.insertOne({
|
||||
id: cast null,
|
||||
name: 'Alice',
|
||||
email: 'alice@example.com',
|
||||
password: 'jew'
|
||||
}).next(function(){
|
||||
db.MUser.select({name: MUser.name, email: MUser.email}).where(MUser.email == 'alice@example.com').first().next(function(row) {
|
||||
trace(row.name);
|
||||
// return "$row";
|
||||
});
|
||||
});
|
||||
}));
|
||||
result.handle(function(outcome) {
|
||||
switch outcome {
|
||||
case Success(data): return data;
|
||||
case Failure(e):
|
||||
trace("failure: "+e);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
return "success";
|
||||
// @await var three = ;
|
||||
// trace(@await one);
|
||||
// trace(@await two);
|
||||
|
||||
@ -13,5 +13,5 @@ typedef Db = tink.sql.Database<Def>;
|
||||
@:tables(MUser)
|
||||
interface Def extends tink.sql.DatabaseDefinition {
|
||||
//@:procedure var func:Int->{x:Int, point:tink.s2d.Point};
|
||||
//@:table('user') var UserAlias:User;
|
||||
@:table('user') var UserAlias:MUser;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user