How to use the sqlite/legacy.get function in sqlite

To help you get started, we’ve selected a few sqlite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cbuntain / collabortweet / server.js View on Github external
app.post('/updateLabel', function(req, res) {
    console.log("Body: " + req.body);
    console.log("\tNew Label ID: " + req.body.newLabelId);
    console.log("\tElement Label ID: " + req.body.elementLabelId);

    // For now, we don't need the user id...
    // console.log("\tUser ID: " + req.session.user.userId);
    // var userId = req.session.user.userId;

    var elementLabelId = req.body.elementLabelId;
    var decision = req.body.newLabelId;

    db.get('UPDATE elementLabels SET labelId = :decision WHERE elementLabelId = :elementLabelId', 
        [decision, elementLabelId])
        .then(function() {
            console.log("Update logged...");
            res.end();
        });
})
github cbuntain / collabortweet / server.js View on Github external
.then(function(pairs) {

			if ( pairs.length > 0 ) {
				var pairList = pairs.map(function(x) {
					return x["pairId"]
				});

				console.log("Found candidiate pairs!");
				// console.log(pairList);
				
				var targetPair = getRandomElement(pairList);
				console.log("Target Pair: " + targetPair);
				
				return Promise.all([
					targetPair,
					db.get('SELECT el.elementId, el.elementText FROM \
						elements el JOIN pairs pr ON pr.leftElement = el.elementId \
						WHERE pr.pairId = ?', targetPair),
					db.get('SELECT el.elementId, el.elementText FROM \
						elements el JOIN pairs pr ON pr.rightElement = el.elementId \
						WHERE pr.pairId = ?', targetPair)
				]);
			} else {
				console.log("No pairs. Done!");
				return Promise.resolve({ empty : true });
			}
		})
		.then(function(tweets) {
github cbuntain / collabortweet / server.js View on Github external
var pairList = pairs.map(function(x) {
					return x["pairId"]
				});

				console.log("Found candidiate pairs!");
				// console.log(pairList);
				
				var targetPair = getRandomElement(pairList);
				console.log("Target Pair: " + targetPair);
				
				return Promise.all([
					targetPair,
					db.get('SELECT el.elementId, el.elementText FROM \
						elements el JOIN pairs pr ON pr.leftElement = el.elementId \
						WHERE pr.pairId = ?', targetPair),
					db.get('SELECT el.elementId, el.elementText FROM \
						elements el JOIN pairs pr ON pr.rightElement = el.elementId \
						WHERE pr.pairId = ?', targetPair)
				]);
			} else {
				console.log("No pairs. Done!");
				return Promise.resolve({ empty : true });
			}
		})
		.then(function(tweets) {
github cbuntain / collabortweet / server.js View on Github external
app.get('/labelerView/:id', function (req, res) {

	// Store the task ID in the session
	var requestedTask = req.params.id
	req.session.taskId = requestedTask

	var currentUser = req.session.user
	console.log("Current User Session: " + currentUser.screenname)

	db.get('SELECT taskName, question FROM tasks WHERE taskId = ?', requestedTask)
		.then(function(taskData) {
			taskMap = {
				taskId: requestedTask,
				taskName: taskData.taskName, 
				question: taskData.question,
			}

			return Promise.all([
				taskMap,
				db.all('SELECT labelId, labelText FROM labels WHERE taskId = ?', requestedTask)
			]);
		})
		.then(function(labelData) {

			var taskData = labelData[0];
			var labelList = labelData[1];
github cbuntain / collabortweet / server.js View on Github external
app.post('/item', function(req, res) {
	console.log("Body: " + req.body);
	console.log("\telement: " + req.body.element);
	console.log("\tselected: " + req.body.selected);
	console.log("\tUser ID: " + req.session.user.userId);

	var elementId = req.body.element;
	var userId = req.session.user.userId;
	var decision = req.body.selected;

	db.get('INSERT INTO elementLabels (elementId, userId, labelId) \
		VALUES (:elementId, :userId, :decision)', [elementId, userId, decision])
		.then(function() {
			console.log("Decision logged...");
			res.end();
		});
})
github cbuntain / collabortweet / server.js View on Github external
app.post('/pair', function(req, res) {
	console.log("Body: " + req.body);
	console.log("\tpair: " + req.body.pair);
	console.log("\tselected: " + req.body.selected);
	console.log("\tUser ID: " + req.session.user.userId);

	var pairId = req.body.pair;
	var userId = req.session.user.userId;
	var decision = req.body.selected;

	db.get('INSERT INTO comparisons (pairId, userId, decision) \
		VALUES (:pairId, :userId, :dec)', [pairId, userId, decision])
		.then(function() {
			console.log("Decision logged...");
			res.end();
		});
})
github cbuntain / collabortweet / server.js View on Github external
app.get('/taskStats/:taskId', function(req, res) {
	var taskId = req.params.taskId

	db.get("SELECT taskName, question, taskType FROM tasks WHERE taskId = ?", taskId)
		.then(function(taskData) {

			var taskDetails = {
                taskInfo: taskData
            };

			if ( taskData.taskType == 1 ) {

				var compDetails = db.all("SELECT c.decision, \
						e1.elementId AS lId, e1.elementText AS lText, e1.externalId AS lExt, \
						e2.elementId AS rId, e2.elementText AS rText, e2.externalId AS rExt \
					FROM pairs p \
						JOIN elements AS e1 ON e1.elementId = p.leftElement \
						JOIN elements AS e2 ON e2.elementId = p.rightElement \
						JOIN comparisons c ON p.pairId = c.pairId \
					WHERE p.taskId = ?", taskId);

sqlite

SQLite client for Node.js applications with SQL-based migrations API written in Typescript

MIT
Latest version published 1 year ago

Package Health Score

65 / 100
Full package analysis