db endpoints design (first iteration) - TrentoCrowdAI/crowdhub-api GitHub Wiki

common attributes for the models
	id  bigserial
	created_at  timestamp
	updated_at timestamp
	deleted_at   timestamp     (NULL means not deleted)


job
	common attrs
	id_requester
	data JSONB
		name, 
		description, 
		numVotes,  // votes per item
		maxVotes,  // max votes per worker
		reward        // how much we pay per vote
		items_csv  // path to items file in the server
		items_gold_csv   //   path to gold items file in the server
		design       // html/text content of the task
		instructions   // html/text content for the instructions of the task
		platform: <>


requester
	common attrs	
	data JSONB
		name, lastname, email, password


item
	common attrs
	id_job
	data JSONB
		gold  <boolean>

predicate
	common attrs
	id_job	
	data JSONB
		description  <string>
		multiple <boolean>  // if true then multiple choice.
		answers: [{description:  <string>, value: <string>}]



GET /jobs
GET /jobs/<job id>
POST /jobs
PUT /jobs/<job id>
DELETE /jobs/<job id>
POST   /jobs/<job id>/publish

Boom.js for displaying errors, each DAO uses try/catch and throws new Error(‘message’)
then one middleware for handling errors and using Boom to wrap the JS Error into a boom error (javascript script error object has a property named message)
⚠️ **GitHub.com Fallback** ⚠️