Compare commits
	
		
			No commits in common. "853f5eba2663c5b8afdebf03d3a0898c37d9f426" and "edc1ea081f74802d9d1428ebe4145724b62ffb9d" have entirely different histories.
		
	
	
		
			853f5eba26
			...
			edc1ea081f
		
	
		
| @ -1,11 +1,9 @@ | ||||
| -lib tink_http | ||||
| -lib tink_web | ||||
| -lib tink_core | ||||
| #-lib tink_hxx | ||||
| -lib tink_json | ||||
| -lib tink_sql | ||||
| -lib hxnodejs | ||||
| # -D await_catch_none | ||||
| -cp src | ||||
| --main Server | ||||
| -js build/out.js | ||||
|  | ||||
							
								
								
									
										1187
									
								
								api/package-lock.json
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1187
									
								
								api/package-lock.json
									
									
									
										generated
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -10,7 +10,6 @@ | ||||
|   "license": "ISC", | ||||
|   "dependencies": { | ||||
|     "mysql": "^2.18.1", | ||||
|     "sqlite": "^4.1.2", | ||||
|     "sqlite3": "^5.0.11" | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -10,7 +10,6 @@ import model.MUser; | ||||
| import controller.IDGen; | ||||
| import controller.User; | ||||
| 
 | ||||
| import db.Db.Database as Db; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| @ -24,7 +23,6 @@ class Server { | ||||
|             .recover(OutgoingResponse.reportError); | ||||
|         }); | ||||
|     } | ||||
|     public static var db: | ||||
| } | ||||
| 
 | ||||
| class Root { | ||||
| @ -65,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') | ||||
|  | ||||
| @ -3,19 +3,13 @@ package controller; | ||||
| import haxe.Json; | ||||
| import Utils; | ||||
| import db.Db; | ||||
| import tink.sql.Fields; | ||||
| import model.MUser; | ||||
| import tink.core.*; | ||||
| 
 | ||||
| using Lambda; | ||||
| using tink.CoreApi; | ||||
| 
 | ||||
| 
 | ||||
| class User{ | ||||
|      | ||||
|     @await private static var database:Db = new Db_DrivebyCool('db.sqlite', driver); | ||||
|     public function new() {} | ||||
|          | ||||
|     public function new() {}     | ||||
|     public static var driver = new tink.sql.drivers.Sqlite(); | ||||
|     @await public static var db = new Db('db.sqlite', driver); | ||||
| 
 | ||||
| 
 | ||||
|     @:get('/') | ||||
| @ -25,88 +19,25 @@ class User{ | ||||
|         return json; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     // @await public function createUserTable():Promise<Bool> | ||||
|     // { | ||||
|     //     // @await var status:Promise<Bool> =; | ||||
|     //     @await var op = db.MUser.create(); | ||||
|     //     op.handle(function(outcome){ | ||||
|     //         switch outcome { | ||||
|     //             case Success(data):  | ||||
|     //                 trace(data); | ||||
|     //                 return data; | ||||
|     //             case Failure(e): | ||||
|     //                 trace("failure: "+e); | ||||
|     //                 return e.data; | ||||
|     //         } | ||||
|     //     }); | ||||
|     //     return true; | ||||
|     // } | ||||
|     @await public function createUserTable():Promise<Bool> | ||||
|     { | ||||
|         // @await var status:Promise<Bool> =; | ||||
|         @await var op = db.MUser.create(); | ||||
|         op.handle(function(outcome){ | ||||
|             switch outcome { | ||||
|                 case Success(data):  | ||||
|                     trace(data); | ||||
|                     //return data; | ||||
|                 case Failure(e): | ||||
|                     trace("failure: "+e); | ||||
|                     //return e.data; | ||||
|             } | ||||
|         }); | ||||
|         return true; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     @:get('/registerDummyUser') | ||||
|     @:produces('application/json') | ||||
|     @:produces('text/plain') | ||||
|     public function registerdummyuser(){ | ||||
|          | ||||
|         //@await var db = new Db('daba2', driver); | ||||
|         // var failed:tink.core.Next<tink.sql.Id<model.MUser>> = null | ||||
|         return createUserTable().next(function(_){ | ||||
|             return db.MUser.insertOne({ | ||||
|         db.MUser.create().next(function(){ | ||||
|             db.MUser.insertOne({ | ||||
|                 id: cast null, | ||||
|                 name: 'Alice', | ||||
|                 email: 'alice@example.com', | ||||
|                 password: 'jew' | ||||
|             }); | ||||
|         }).next(function(_){ | ||||
|             return db.MUser.select({id: MUser.id, name: MUser.name, email: MUser.email, password: MUser.password}).where(MUser.id == _).first().next(function(row) { | ||||
|                 return row; | ||||
|             }).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"; | ||||
|                 }); | ||||
|             }); | ||||
|         }); | ||||
|         // @await var createTable = db.MUser.create().handle(function(outcome) { | ||||
|         //     @await var insert = db.MUser.insertOne({ | ||||
|         //             id: cast null, | ||||
|         //             name: 'Alice', | ||||
|         //             email: 'alice@example.com', | ||||
|         //             password: 'jew' | ||||
|         //     }).next(function(_){ | ||||
|         //         trace(_); | ||||
|         //         trace("wat"); | ||||
|         //         return { name: "klaas" }; | ||||
|         //     }); | ||||
|         //     trace(@await result); | ||||
|         //     switch outcome { | ||||
|         //         case Success(data):  | ||||
|         //             trace(data); | ||||
|         //             return data; | ||||
|         //         case Failure(e): | ||||
|         //             trace("failure: "+e); | ||||
|         //             return e.data; | ||||
|         //     } | ||||
|         //     return outcome; | ||||
|         // }); | ||||
|          | ||||
|         // trace(@await result); | ||||
|         // trace("kak"); | ||||
|         // trace(result.status); | ||||
|         //return result; | ||||
|         // return {name: "Kees"}; | ||||
|         //@await return result.next.; | ||||
|         //@await return result; | ||||
|         return "success"; | ||||
|         // @await var three = ; | ||||
|         // trace(@await one); | ||||
|         // trace(@await two); | ||||
|  | ||||
| @ -4,26 +4,14 @@ package db; | ||||
| //import tink.sql.Database; | ||||
| import tink.sql.Types; | ||||
| import model.MUser; | ||||
| import model.services.DrivebyCool; | ||||
| 
 | ||||
|   @:tables(MUser) | ||||
|   @:tables(MProject) | ||||
| // Post related Tables | ||||
|   @:tables(MPost) | ||||
|   @:tables(MTag) | ||||
|   @:tables(MPostTag) | ||||
| interface DbDef_DrivebyCool extends tink.sql.DatabaseDefinition { | ||||
| // import db.Models.User; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| 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 UserTbl:MUser; | ||||
|   // @:table('project') var ProjectTbl:DrivebyCool.MProject; | ||||
| } | ||||
| 
 | ||||
| class Database extends tink.sql.Database<Def> { | ||||
|   public function new(__name:String,driver:tink.sql.Driver){ | ||||
|     super(__name, driver); | ||||
|   } | ||||
|   public static function createTables():Void | ||||
|   { | ||||
| 
 | ||||
|   } | ||||
|   //@:table('user') var UserAlias:User; | ||||
| } | ||||
| @ -1,60 +1,17 @@ | ||||
| package model.services; | ||||
| package model.sites.drivebycool; | ||||
| 
 | ||||
| import tink.sql.Types; | ||||
| import model.MSubscription; | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /* | ||||
|  *      Project related models | ||||
| */ | ||||
| 
 | ||||
| 
 | ||||
| //      Defines a Project to be listed on the projects page | ||||
| typedef MProject = { | ||||
|     @:autoIncrement @:primary public var id(default, null):Id<MProject>; | ||||
|     // Properties | ||||
|     public var name:VarChar<50>; | ||||
|     public var owner:Id<MUser>; | ||||
|     public var description:VarChar<1024>; | ||||
| } | ||||
| 
 | ||||
| //      Defines a relationship between a Project and a User. The User will be added as a member of the project and can author blogposts | ||||
| typedef MMembership = { | ||||
|     @:autoIncrement @:primary public var id(default, null):Id<MMembership>; | ||||
|     // relationships | ||||
|     public var project:Id<MProject>; | ||||
|     public var user:Id<MUser>; | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| /*  | ||||
|  *      Defines a Post | ||||
|  */ | ||||
| typedef MPost = { | ||||
|     @:autoIncrement @:primary public var id(default, null):Id<MPost>; | ||||
|     // Relationships | ||||
|     public var project:Id<MProject>; | ||||
|     public var owner:Id<MUser>; | ||||
|     // Properties | ||||
|     public var title:VarChar<1024>; | ||||
|     public var description:Text; | ||||
|     public var content:Text; | ||||
| } | ||||
| 
 | ||||
| // | ||||
| //      Defines a tag that can be added to any post. | ||||
| // | ||||
| typedef MTag = { | ||||
|     @:autoIncrement @:primary public var id(default, null):Id<MTag>; | ||||
|     public var title:VarChar<32>; | ||||
| } | ||||
| 
 | ||||
| // | ||||
| //      Defines a relationship between a tag and a post. | ||||
| // | ||||
| typedef MTaggedPost = { | ||||
|     @:autoIncrement @:primary public var id(default, null):Id<MTaggedPost>; | ||||
|     public var post:Id<MPost>; | ||||
|     public var tag:Id<MTag>; | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user