Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

easiest way to delete 1 element from array in field? #67

Open
mspanish opened this issue Jun 18, 2017 · 1 comment
Open

easiest way to delete 1 element from array in field? #67

mspanish opened this issue Jun 18, 2017 · 1 comment

Comments

@mspanish
Copy link

Hello and thanks again for this great app! I've hacked it up so that I can view colors from arrays inside of fields, and I'm planning to try and expose a new route that deletes any color I click on. Hackish I know! But would serve my needs for now. Is there any better way to do this? If anybody wants my hack I'll post it - here's a screenshot.
colors_hack

@mspanish
Copy link
Author

mspanish commented Jun 19, 2017

Got it working! Created a simple route like this:

exports.removeColor = function (req, res) {
	var primaryKey = req.body.primary;
	var db = req.body.db;
	var table = req.body.table;
	var colors = req.body.colors;

r.db(db).table(table).get(primaryKey).update({colors:colors}).run( connection, {timeFormat: 'raw'}, function(error, result) {
		if (error) handleError(error);
		res.json({
			error: error,
			result: result
		});
	})
}

Then when I click on a color, I pass the id and the new color array (I added lodash to the front end to do that quickly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant