Various changes
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
package controller;
|
||||
|
||||
import haxe.Json;
|
||||
import Utils;
|
||||
import db.Db;
|
||||
import model.MUser;
|
||||
|
||||
|
||||
class User{
|
||||
public function new() {}
|
||||
public static var driver = new tink.sql.drivers.Sqlite();
|
||||
@await public static var db = new Db('db.sqlite', driver);
|
||||
|
||||
|
||||
@:get('/')
|
||||
@:produces('text/plain')
|
||||
public function id(){
|
||||
var json:String = "test";
|
||||
return json;
|
||||
}
|
||||
|
||||
@:get('/registerDummyUser')
|
||||
@:produces('text/plain')
|
||||
public function registerdummyuser(){
|
||||
|
||||
//@await var db = new Db('daba2', driver);
|
||||
db.MUser.create().next(function(){
|
||||
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";
|
||||
})
|
||||
});
|
||||
});
|
||||
return "success";
|
||||
// @await var three = ;
|
||||
// trace(@await one);
|
||||
// trace(@await two);
|
||||
// trace(three);
|
||||
//return '$yeet';
|
||||
// var json:String = Json.stringify(three);
|
||||
// @await return json;
|
||||
}
|
||||
|
||||
@:get('/fetchalice')
|
||||
@:produces('application/json')
|
||||
public function fetchalice(){
|
||||
var driver = new tink.sql.drivers.Sqlite();
|
||||
|
||||
return db.MUser.select({name: MUser.name, email: MUser.email}).where(MUser.email == 'alice@example.com').first().next(function(row) {
|
||||
return row;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user