mirror of
				https://github.com/Jermolene/TiddlyWiki5
				synced 2025-10-31 07:32:59 +00:00 
			
		
		
		
	More consistent variable naming
This commit is contained in:
		| @@ -27,7 +27,7 @@ Command.prototype.execute = function() { | ||||
| 	var self = this; | ||||
| 	// Check parameters | ||||
| 	if(this.params.length < 2) { | ||||
| 		return "Missing pathname and/or bagname"; | ||||
| 		return "Missing pathname and/or bag name"; | ||||
| 	} | ||||
| 	var tiddlersPath = this.params[0], | ||||
| 		bagName = this.params[1]; | ||||
|   | ||||
| @@ -38,7 +38,7 @@ exports.handler = function(request,response,state) { | ||||
| 		store: $tw.mws.store, | ||||
| 		state: state, | ||||
| 		response: response, | ||||
| 		bagname: bag_name, | ||||
| 		bag_name: bag_name, | ||||
| 		callback: function(err,results) { | ||||
| 			// If application/json is requested then this is an API request, and gets the response in JSON | ||||
| 			if(request.headers.accept && request.headers.accept.indexOf("application/json") !== -1) { | ||||
|   | ||||
| @@ -16,7 +16,7 @@ Process an incoming new multipart/form-data stream. Options include: | ||||
| store - tiddler store | ||||
| state - provided by server.js | ||||
| response - provided by server.js | ||||
| bagname - name of bag to write to | ||||
| bag_name - name of bag to write to | ||||
| callback - invoked as callback(err,results). Results is an array of titles of imported tiddlers | ||||
| */ | ||||
| exports.processIncomingStream = function(options) { | ||||
| @@ -85,7 +85,7 @@ exports.processIncomingStream = function(options) { | ||||
| 						tiddlerFields[part.name.slice(tiddlerFieldPrefix.length)] = part.value.trim(); | ||||
| 					} | ||||
| 				} | ||||
| 				options.store.saveBagTiddlerWithAttachment(tiddlerFields,options.bagname,{ | ||||
| 				options.store.saveBagTiddlerWithAttachment(tiddlerFields,options.bag_name,{ | ||||
| 					filepath: partFile.inboxFilename, | ||||
| 					type: type, | ||||
| 					hash: partFile.hash | ||||
|   | ||||
| @@ -42,9 +42,9 @@ function AttachmentStore(options) { | ||||
| /* | ||||
| Check if an attachment name is valid | ||||
| */ | ||||
| AttachmentStore.prototype.isValidAttachmentName = function(attachmentname) { | ||||
| AttachmentStore.prototype.isValidAttachmentName = function(attachment_name) { | ||||
|     const re = new RegExp('^[a-f0-9]{64}$'); | ||||
| 	return re.test(attachmentname); | ||||
| 	return re.test(attachment_name); | ||||
| }; | ||||
|  | ||||
| /* | ||||
| @@ -107,13 +107,13 @@ Get an attachment ready to stream. Returns null if there is an error or: | ||||
| stream: filestream of file | ||||
| type: type of file | ||||
| */ | ||||
| AttachmentStore.prototype.getAttachmentStream = function(attachmentname) { | ||||
| AttachmentStore.prototype.getAttachmentStream = function(attachment_name) { | ||||
| 	const path = require("path"), | ||||
| 		fs = require("fs"); | ||||
| 	// Check the attachment name | ||||
| 	if(this.isValidAttachmentName(attachmentname)) { | ||||
| 	if(this.isValidAttachmentName(attachment_name)) { | ||||
| 		// Construct the path to the attachment directory | ||||
| 		const attachmentPath = path.resolve(this.storePath,"files",attachmentname); | ||||
| 		const attachmentPath = path.resolve(this.storePath,"files",attachment_name); | ||||
| 		// Read the meta.json file | ||||
| 		const metaJsonPath = path.resolve(attachmentPath,"meta.json"); | ||||
| 		if(fs.existsSync(metaJsonPath) && fs.statSync(metaJsonPath).isFile()) { | ||||
|   | ||||
| @@ -94,14 +94,14 @@ SqlTiddlerDatabase.prototype.listBags = function() { | ||||
| 	return rows; | ||||
| }; | ||||
|  | ||||
| SqlTiddlerDatabase.prototype.createBag = function(bagname,description,accesscontrol) { | ||||
| SqlTiddlerDatabase.prototype.createBag = function(bag_name,description,accesscontrol) { | ||||
| 	accesscontrol = accesscontrol || ""; | ||||
| 	// Run the queries | ||||
| 	this.engine.runStatement(` | ||||
| 		INSERT OR IGNORE INTO bags (bag_name, accesscontrol, description) | ||||
| 		VALUES ($bag_name, '', '') | ||||
| 	`,{ | ||||
| 		$bag_name: bagname | ||||
| 		$bag_name: bag_name | ||||
| 	}); | ||||
| 	this.engine.runStatement(` | ||||
| 		UPDATE bags | ||||
| @@ -109,7 +109,7 @@ SqlTiddlerDatabase.prototype.createBag = function(bagname,description,accesscont | ||||
| 		description = $description  | ||||
| 		WHERE bag_name = $bag_name | ||||
| 	`,{ | ||||
| 		$bag_name: bagname, | ||||
| 		$bag_name: bag_name, | ||||
| 		$accesscontrol: accesscontrol, | ||||
| 		$description: description | ||||
| 	}); | ||||
| @@ -143,20 +143,20 @@ SqlTiddlerDatabase.prototype.listRecipes = function() { | ||||
| 	return results; | ||||
| }; | ||||
|  | ||||
| SqlTiddlerDatabase.prototype.createRecipe = function(recipename,bagnames,description) { | ||||
| SqlTiddlerDatabase.prototype.createRecipe = function(recipe_name,bag_names,description) { | ||||
| 	// Run the queries | ||||
| 	this.engine.runStatement(` | ||||
| 		-- Delete existing recipe_bags entries for this recipe | ||||
| 		DELETE FROM recipe_bags WHERE recipe_id = (SELECT recipe_id FROM recipes WHERE recipe_name = $recipe_name) | ||||
| 	`,{ | ||||
| 		$recipe_name: recipename | ||||
| 		$recipe_name: recipe_name | ||||
| 	}); | ||||
| 	this.engine.runStatement(` | ||||
| 		-- Create the entry in the recipes table if required | ||||
| 		INSERT OR REPLACE INTO recipes (recipe_name, description) | ||||
| 		VALUES ($recipe_name, $description) | ||||
| 	`,{ | ||||
| 		$recipe_name: recipename, | ||||
| 		$recipe_name: recipe_name, | ||||
| 		$description: description | ||||
| 	}); | ||||
| 	this.engine.runStatement(` | ||||
| @@ -167,15 +167,15 @@ SqlTiddlerDatabase.prototype.createRecipe = function(recipename,bagnames,descrip | ||||
| 		INNER JOIN json_each($bag_names) AS j ON j.value = b.bag_name | ||||
| 		WHERE r.recipe_name = $recipe_name | ||||
| 	`,{ | ||||
| 		$recipe_name: recipename, | ||||
| 		$bag_names: JSON.stringify(bagnames) | ||||
| 		$recipe_name: recipe_name, | ||||
| 		$bag_names: JSON.stringify(bag_names) | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| /* | ||||
| Returns {tiddler_id:} | ||||
| */ | ||||
| SqlTiddlerDatabase.prototype.saveBagTiddler = function(tiddlerFields,bagname,attachment_blob) { | ||||
| SqlTiddlerDatabase.prototype.saveBagTiddler = function(tiddlerFields,bag_name,attachment_blob) { | ||||
| 	attachment_blob = attachment_blob || null; | ||||
| 	// Update the tiddlers table | ||||
| 	var info = this.engine.runStatement(` | ||||
| @@ -189,7 +189,7 @@ SqlTiddlerDatabase.prototype.saveBagTiddler = function(tiddlerFields,bagname,att | ||||
| 	`,{ | ||||
| 		$title: tiddlerFields.title, | ||||
| 		$attachment_blob: attachment_blob, | ||||
| 		$bag_name: bagname | ||||
| 		$bag_name: bag_name | ||||
| 	}); | ||||
| 	// Update the fields table | ||||
| 	this.engine.runStatement(` | ||||
| @@ -210,7 +210,7 @@ SqlTiddlerDatabase.prototype.saveBagTiddler = function(tiddlerFields,bagname,att | ||||
| 		JOIN json_each($field_values) AS json_each | ||||
| 	`,{ | ||||
| 		$title: tiddlerFields.title, | ||||
| 		$bag_name: bagname, | ||||
| 		$bag_name: bag_name, | ||||
| 		$field_values: JSON.stringify(Object.assign({},tiddlerFields,{title: undefined})) | ||||
| 	}); | ||||
| 	return { | ||||
| @@ -221,7 +221,7 @@ SqlTiddlerDatabase.prototype.saveBagTiddler = function(tiddlerFields,bagname,att | ||||
| /* | ||||
| Returns {tiddler_id:,bag_name:} or null if the recipe is empty | ||||
| */ | ||||
| SqlTiddlerDatabase.prototype.saveRecipeTiddler = function(tiddlerFields,recipename,attachment_blob) { | ||||
| SqlTiddlerDatabase.prototype.saveRecipeTiddler = function(tiddlerFields,recipe_name,attachment_blob) { | ||||
| 	// Find the topmost bag in the recipe | ||||
| 	var row = this.engine.runStatementGet(` | ||||
| 		SELECT b.bag_name | ||||
| @@ -239,7 +239,7 @@ SqlTiddlerDatabase.prototype.saveRecipeTiddler = function(tiddlerFields,recipena | ||||
| 		) AS selected_bag | ||||
| 		ON b.bag_id = selected_bag.bag_id | ||||
| 	`,{ | ||||
| 		$recipe_name: recipename | ||||
| 		$recipe_name: recipe_name | ||||
| 	}); | ||||
| 	if(!row) { | ||||
| 		return null; | ||||
| @@ -252,7 +252,7 @@ SqlTiddlerDatabase.prototype.saveRecipeTiddler = function(tiddlerFields,recipena | ||||
| 	}; | ||||
| }; | ||||
|  | ||||
| SqlTiddlerDatabase.prototype.deleteTiddler = function(title,bagname) { | ||||
| SqlTiddlerDatabase.prototype.deleteTiddler = function(title,bag_name) { | ||||
| 	// Delete the fields of this tiddler | ||||
| 	this.engine.runStatement(` | ||||
| 		DELETE FROM fields | ||||
| @@ -264,7 +264,7 @@ SqlTiddlerDatabase.prototype.deleteTiddler = function(title,bagname) { | ||||
| 		) | ||||
| 	`,{ | ||||
| 		$title: title, | ||||
| 		$bag_name: bagname | ||||
| 		$bag_name: bag_name | ||||
| 	}); | ||||
| 	// Mark the tiddler itself as deleted | ||||
| 	this.engine.runStatement(` | ||||
| @@ -277,14 +277,14 @@ SqlTiddlerDatabase.prototype.deleteTiddler = function(title,bagname) { | ||||
| 		) | ||||
| 	`,{ | ||||
| 		$title: title, | ||||
| 		$bag_name: bagname | ||||
| 		$bag_name: bag_name | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| /* | ||||
| returns {tiddler_id:,tiddler:,attachment_blob:} | ||||
| */ | ||||
| SqlTiddlerDatabase.prototype.getBagTiddler = function(title,bagname) { | ||||
| SqlTiddlerDatabase.prototype.getBagTiddler = function(title,bag_name) { | ||||
| 	const rowTiddler = this.engine.runStatementGet(` | ||||
| 		SELECT t.tiddler_id, t.attachment_blob | ||||
| 		FROM bags AS b | ||||
| @@ -292,7 +292,7 @@ SqlTiddlerDatabase.prototype.getBagTiddler = function(title,bagname) { | ||||
| 		WHERE t.title = $title AND b.bag_name = $bag_name AND t.is_deleted = FALSE | ||||
| 	`,{ | ||||
| 		$title: title, | ||||
| 		$bag_name: bagname | ||||
| 		$bag_name: bag_name | ||||
| 	}); | ||||
| 	if(!rowTiddler) { | ||||
| 		return null; | ||||
| @@ -321,7 +321,7 @@ SqlTiddlerDatabase.prototype.getBagTiddler = function(title,bagname) { | ||||
| /* | ||||
| Returns {bag_name:, tiddler: {fields}, tiddler_id:, attachment_blob:} | ||||
| */ | ||||
| SqlTiddlerDatabase.prototype.getRecipeTiddler = function(title,recipename) { | ||||
| SqlTiddlerDatabase.prototype.getRecipeTiddler = function(title,recipe_name) { | ||||
| 	const rowTiddlerId = this.engine.runStatementGet(`	 | ||||
| 		SELECT t.tiddler_id, t.attachment_blob, b.bag_name | ||||
| 		FROM bags AS b | ||||
| @@ -335,7 +335,7 @@ SqlTiddlerDatabase.prototype.getRecipeTiddler = function(title,recipename) { | ||||
| 		LIMIT 1 | ||||
| 	`,{ | ||||
| 		$title: title, | ||||
| 		$recipe_name: recipename | ||||
| 		$recipe_name: recipe_name | ||||
| 	}); | ||||
| 	if(!rowTiddlerId) { | ||||
| 		return null; | ||||
| @@ -362,7 +362,7 @@ SqlTiddlerDatabase.prototype.getRecipeTiddler = function(title,recipename) { | ||||
| /* | ||||
| Get the titles of the tiddlers in a bag. Returns an empty array for bags that do not exist | ||||
| */ | ||||
| SqlTiddlerDatabase.prototype.getBagTiddlers = function(bagname) { | ||||
| SqlTiddlerDatabase.prototype.getBagTiddlers = function(bag_name) { | ||||
| 	const rows = this.engine.runStatementGetAll(` | ||||
| 		SELECT DISTINCT title | ||||
| 		FROM tiddlers | ||||
| @@ -374,7 +374,7 @@ SqlTiddlerDatabase.prototype.getBagTiddlers = function(bagname) { | ||||
| 		AND tiddlers.is_deleted = FALSE | ||||
| 		ORDER BY title ASC | ||||
| 	`,{ | ||||
| 		$bag_name: bagname | ||||
| 		$bag_name: bag_name | ||||
| 	}); | ||||
| 	return rows.map(value => value.title); | ||||
| }; | ||||
| @@ -382,11 +382,11 @@ SqlTiddlerDatabase.prototype.getBagTiddlers = function(bagname) { | ||||
| /* | ||||
| Get the titles of the tiddlers in a recipe as {title:,bag_name:}. Returns null for recipes that do not exist | ||||
| */ | ||||
| SqlTiddlerDatabase.prototype.getRecipeTiddlers = function(recipename) { | ||||
| SqlTiddlerDatabase.prototype.getRecipeTiddlers = function(recipe_name) { | ||||
| 	const rowsCheckRecipe = this.engine.runStatementGetAll(` | ||||
| 		SELECT * FROM recipes WHERE recipes.recipe_name = $recipe_name | ||||
| 	`,{ | ||||
| 		$recipe_name: recipename | ||||
| 		$recipe_name: recipe_name | ||||
| 	}); | ||||
| 	if(rowsCheckRecipe.length === 0) { | ||||
| 		return null; | ||||
| @@ -405,12 +405,12 @@ SqlTiddlerDatabase.prototype.getRecipeTiddlers = function(recipename) { | ||||
| 			ORDER BY t.title | ||||
| 		) | ||||
| 	`,{ | ||||
| 		$recipe_name: recipename | ||||
| 		$recipe_name: recipe_name | ||||
| 	}); | ||||
| 	return rows; | ||||
| }; | ||||
|  | ||||
| SqlTiddlerDatabase.prototype.deleteAllTiddlersInBag = function(bagname) { | ||||
| SqlTiddlerDatabase.prototype.deleteAllTiddlersInBag = function(bag_name) { | ||||
| 	// Delete the fields | ||||
| 	this.engine.runStatement(` | ||||
| 		DELETE FROM fields | ||||
| @@ -421,7 +421,7 @@ SqlTiddlerDatabase.prototype.deleteAllTiddlersInBag = function(bagname) { | ||||
| 			AND is_deleted = FALSE | ||||
| 		) | ||||
| 	`,{ | ||||
| 		$bag_name: bagname | ||||
| 		$bag_name: bag_name | ||||
| 	}); | ||||
| 	// Mark the tiddlers as deleted | ||||
| 	this.engine.runStatement(` | ||||
| @@ -430,14 +430,14 @@ SqlTiddlerDatabase.prototype.deleteAllTiddlersInBag = function(bagname) { | ||||
| 		WHERE bag_id = (SELECT bag_id FROM bags WHERE bag_name = $bag_name) | ||||
| 		AND is_deleted = FALSE | ||||
| 	`,{ | ||||
| 		$bag_name: bagname | ||||
| 		$bag_name: bag_name | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| /* | ||||
| Get the names of the bags in a recipe. Returns an empty array for recipes that do not exist | ||||
| */ | ||||
| SqlTiddlerDatabase.prototype.getRecipeBags = function(recipename) { | ||||
| SqlTiddlerDatabase.prototype.getRecipeBags = function(recipe_name) { | ||||
| 	const rows = this.engine.runStatementGetAll(` | ||||
| 		SELECT bags.bag_name | ||||
| 		FROM bags | ||||
| @@ -450,7 +450,7 @@ SqlTiddlerDatabase.prototype.getRecipeBags = function(recipename) { | ||||
| 		) AS bag_priority ON bags.bag_id = bag_priority.bag_id | ||||
| 		ORDER BY position | ||||
| 	`,{ | ||||
| 		$recipe_name: recipename | ||||
| 		$recipe_name: recipe_name | ||||
| 	}); | ||||
| 	return rows.map(value => value.bag_name); | ||||
| }; | ||||
|   | ||||
| @@ -112,7 +112,7 @@ SqlTiddlerStore.prototype.updateAdminWiki = function() { | ||||
| }; | ||||
|  | ||||
| /* | ||||
| Given tiddler fields, tiddler_id and a bagname, return the tiddler fields after the following process: | ||||
| Given tiddler fields, tiddler_id and a bag_name, return the tiddler fields after the following process: | ||||
| - Apply the tiddler_id as the revision field | ||||
| - Apply the bag_name as the bag field | ||||
| */ | ||||
| @@ -174,17 +174,17 @@ SqlTiddlerStore.prototype.listBags = function() { | ||||
| 	return this.sqlTiddlerDatabase.listBags(); | ||||
| }; | ||||
|  | ||||
| SqlTiddlerStore.prototype.createBag = function(bagname,description) { | ||||
| SqlTiddlerStore.prototype.createBag = function(bag_name,description) { | ||||
| 	var self = this; | ||||
| 	return this.sqlTiddlerDatabase.transaction(function() { | ||||
| 		const validationBagName = self.validateItemName(bagname); | ||||
| 		const validationBagName = self.validateItemName(bag_name); | ||||
| 		if(validationBagName) { | ||||
| 			return {message: validationBagName}; | ||||
| 		} | ||||
| 		self.sqlTiddlerDatabase.createBag(bagname,description); | ||||
| 		self.sqlTiddlerDatabase.createBag(bag_name,description); | ||||
| 		self.saveEntityStateTiddler({ | ||||
| 			title: "bags/" + bagname, | ||||
| 			"bag-name": bagname, | ||||
| 			title: "bags/" + bag_name, | ||||
| 			"bag-name": bag_name, | ||||
| 			text: description | ||||
| 		}); | ||||
| 		return null; | ||||
| @@ -198,28 +198,28 @@ SqlTiddlerStore.prototype.listRecipes = function() { | ||||
| /* | ||||
| Returns null on success, or {message:} on error | ||||
| */ | ||||
| SqlTiddlerStore.prototype.createRecipe = function(recipename,bagnames,description) { | ||||
| 	bagnames = bagnames || []; | ||||
| SqlTiddlerStore.prototype.createRecipe = function(recipe_name,bag_names,description) { | ||||
| 	bag_names = bag_names || []; | ||||
| 	description = description || ""; | ||||
| 	const validationRecipeName = this.validateItemName(recipename); | ||||
| 	const validationRecipeName = this.validateItemName(recipe_name); | ||||
| 	if(validationRecipeName) { | ||||
| 		return {message: validationRecipeName}; | ||||
| 	} | ||||
| 	const validationBagNames = this.validateItemNames(bagnames); | ||||
| 	const validationBagNames = this.validateItemNames(bag_names); | ||||
| 	if(validationBagNames) { | ||||
| 		return {message: validationBagNames}; | ||||
| 	} | ||||
| 	if(bagnames.length === 0) { | ||||
| 	if(bag_names.length === 0) { | ||||
| 		return {message: "Recipes must contain at least one bag"}; | ||||
| 	} | ||||
| 	var self = this; | ||||
| 	return this.sqlTiddlerDatabase.transaction(function() { | ||||
| 		self.sqlTiddlerDatabase.createRecipe(recipename,bagnames,description); | ||||
| 		self.sqlTiddlerDatabase.createRecipe(recipe_name,bag_names,description); | ||||
| 		self.saveEntityStateTiddler({ | ||||
| 			title: "recipes/" + recipename, | ||||
| 			"recipe-name": recipename, | ||||
| 			title: "recipes/" + recipe_name, | ||||
| 			"recipe-name": recipe_name, | ||||
| 			text: description, | ||||
| 			list: $tw.utils.stringifyList(bagnames.map(bag_name => { | ||||
| 			list: $tw.utils.stringifyList(bag_names.map(bag_name => { | ||||
| 				return self.entityStateTiddlerPrefix + "bags/" + bag_name; | ||||
| 			})) | ||||
| 		}); | ||||
| @@ -230,9 +230,9 @@ SqlTiddlerStore.prototype.createRecipe = function(recipename,bagnames,descriptio | ||||
| /* | ||||
| Returns {tiddler_id:} | ||||
| */ | ||||
| SqlTiddlerStore.prototype.saveBagTiddler = function(incomingTiddlerFields,bagname) { | ||||
| SqlTiddlerStore.prototype.saveBagTiddler = function(incomingTiddlerFields,bag_name) { | ||||
| 	const {tiddlerFields, attachment_blob} = this.processIncomingTiddler(incomingTiddlerFields); | ||||
| 	return this.sqlTiddlerDatabase.saveBagTiddler(tiddlerFields,bagname,attachment_blob); | ||||
| 	return this.sqlTiddlerDatabase.saveBagTiddler(tiddlerFields,bag_name,attachment_blob); | ||||
| }; | ||||
|  | ||||
| /* | ||||
| @@ -245,10 +245,10 @@ type - content type of file as uploaded | ||||
|  | ||||
| Returns {tiddler_id:} | ||||
| */ | ||||
| SqlTiddlerStore.prototype.saveBagTiddlerWithAttachment = function(incomingTiddlerFields,bagname,options) { | ||||
| SqlTiddlerStore.prototype.saveBagTiddlerWithAttachment = function(incomingTiddlerFields,bag_name,options) { | ||||
| 	const attachment_blob = this.attachmentStore.adoptAttachment(options.filepath,options.type,options.hash); | ||||
| 	if(attachment_blob) { | ||||
| 		return this.sqlTiddlerDatabase.saveBagTiddler(incomingTiddlerFields,bagname,attachment_blob); | ||||
| 		return this.sqlTiddlerDatabase.saveBagTiddler(incomingTiddlerFields,bag_name,attachment_blob); | ||||
| 	} else { | ||||
| 		return null; | ||||
| 	} | ||||
| @@ -257,26 +257,26 @@ SqlTiddlerStore.prototype.saveBagTiddlerWithAttachment = function(incomingTiddle | ||||
| /* | ||||
| Returns {tiddler_id:,bag_name:} | ||||
| */ | ||||
| SqlTiddlerStore.prototype.saveRecipeTiddler = function(incomingTiddlerFields,recipename) { | ||||
| SqlTiddlerStore.prototype.saveRecipeTiddler = function(incomingTiddlerFields,recipe_name) { | ||||
| 	const {tiddlerFields, attachment_blob} = this.processIncomingTiddler(incomingTiddlerFields); | ||||
| 	return this.sqlTiddlerDatabase.saveRecipeTiddler(tiddlerFields,recipename,attachment_blob); | ||||
| 	return this.sqlTiddlerDatabase.saveRecipeTiddler(tiddlerFields,recipe_name,attachment_blob); | ||||
| }; | ||||
|  | ||||
| SqlTiddlerStore.prototype.deleteTiddler = function(title,bagname) { | ||||
| 	this.sqlTiddlerDatabase.deleteTiddler(title,bagname); | ||||
| SqlTiddlerStore.prototype.deleteTiddler = function(title,bag_name) { | ||||
| 	this.sqlTiddlerDatabase.deleteTiddler(title,bag_name); | ||||
| }; | ||||
|  | ||||
| /* | ||||
| returns {tiddler_id:,tiddler:} | ||||
| */ | ||||
| SqlTiddlerStore.prototype.getBagTiddler = function(title,bagname) { | ||||
| 	var tiddlerInfo = this.sqlTiddlerDatabase.getBagTiddler(title,bagname); | ||||
| SqlTiddlerStore.prototype.getBagTiddler = function(title,bag_name) { | ||||
| 	var tiddlerInfo = this.sqlTiddlerDatabase.getBagTiddler(title,bag_name); | ||||
| 	if(tiddlerInfo) { | ||||
| 		return Object.assign( | ||||
| 			{}, | ||||
| 			tiddlerInfo, | ||||
| 			{ | ||||
| 				tiddler: this.processOutgoingTiddler(tiddlerInfo.tiddler,tiddlerInfo.tiddler_id,bagname,tiddlerInfo.attachment_blob) | ||||
| 				tiddler: this.processOutgoingTiddler(tiddlerInfo.tiddler,tiddlerInfo.tiddler_id,bag_name,tiddlerInfo.attachment_blob) | ||||
| 			});	 | ||||
| 	} else { | ||||
| 		return null; | ||||
| @@ -288,8 +288,8 @@ Get an attachment ready to stream. Returns null if there is an error or: | ||||
| stream: stream of file | ||||
| type: type of file | ||||
| */ | ||||
| SqlTiddlerStore.prototype.getBagTiddlerStream = function(title,bagname) { | ||||
| 	const tiddlerInfo = this.sqlTiddlerDatabase.getBagTiddler(title,bagname); | ||||
| SqlTiddlerStore.prototype.getBagTiddlerStream = function(title,bag_name) { | ||||
| 	const tiddlerInfo = this.sqlTiddlerDatabase.getBagTiddler(title,bag_name); | ||||
| 	if(tiddlerInfo) { | ||||
| 		if(tiddlerInfo.attachment_blob) { | ||||
| 			return this.attachmentStore.getAttachmentStream(tiddlerInfo.attachment_blob); | ||||
| @@ -316,8 +316,8 @@ SqlTiddlerStore.prototype.getBagTiddlerStream = function(title,bagname) { | ||||
| /* | ||||
| Returns {bag_name:, tiddler: {fields}, tiddler_id:} | ||||
| */ | ||||
| SqlTiddlerStore.prototype.getRecipeTiddler = function(title,recipename) { | ||||
| 	var tiddlerInfo = this.sqlTiddlerDatabase.getRecipeTiddler(title,recipename); | ||||
| SqlTiddlerStore.prototype.getRecipeTiddler = function(title,recipe_name) { | ||||
| 	var tiddlerInfo = this.sqlTiddlerDatabase.getRecipeTiddler(title,recipe_name); | ||||
| 	if(tiddlerInfo) { | ||||
| 		return Object.assign( | ||||
| 			{}, | ||||
| @@ -333,29 +333,29 @@ SqlTiddlerStore.prototype.getRecipeTiddler = function(title,recipename) { | ||||
| /* | ||||
| Get the titles of the tiddlers in a bag. Returns an empty array for bags that do not exist | ||||
| */ | ||||
| SqlTiddlerStore.prototype.getBagTiddlers = function(bagname) { | ||||
| 	return this.sqlTiddlerDatabase.getBagTiddlers(bagname); | ||||
| SqlTiddlerStore.prototype.getBagTiddlers = function(bag_name) { | ||||
| 	return this.sqlTiddlerDatabase.getBagTiddlers(bag_name); | ||||
| }; | ||||
|  | ||||
| /* | ||||
| Get the titles of the tiddlers in a recipe as {title:,bag_name:}. Returns null for recipes that do not exist | ||||
| */ | ||||
| SqlTiddlerStore.prototype.getRecipeTiddlers = function(recipename) { | ||||
| 	return this.sqlTiddlerDatabase.getRecipeTiddlers(recipename); | ||||
| SqlTiddlerStore.prototype.getRecipeTiddlers = function(recipe_name) { | ||||
| 	return this.sqlTiddlerDatabase.getRecipeTiddlers(recipe_name); | ||||
| }; | ||||
|  | ||||
| SqlTiddlerStore.prototype.deleteAllTiddlersInBag = function(bagname) { | ||||
| SqlTiddlerStore.prototype.deleteAllTiddlersInBag = function(bag_name) { | ||||
| 	var self = this; | ||||
| 	return this.sqlTiddlerDatabase.transaction(function() { | ||||
| 		return self.sqlTiddlerDatabase.deleteAllTiddlersInBag(bagname); | ||||
| 		return self.sqlTiddlerDatabase.deleteAllTiddlersInBag(bag_name); | ||||
| 	}); | ||||
| }; | ||||
|  | ||||
| /* | ||||
| Get the names of the bags in a recipe. Returns an empty array for recipes that do not exist | ||||
| */ | ||||
| SqlTiddlerStore.prototype.getRecipeBags = function(recipename) { | ||||
| 	return this.sqlTiddlerDatabase.getRecipeBags(recipename); | ||||
| SqlTiddlerStore.prototype.getRecipeBags = function(recipe_name) { | ||||
| 	return this.sqlTiddlerDatabase.getRecipeBags(recipe_name); | ||||
| }; | ||||
|  | ||||
| exports.SqlTiddlerStore = SqlTiddlerStore; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jeremy Ruston
					Jeremy Ruston