Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I'm trying to show an image that a user has uploaded as part of a recipe but keep getting an error:
Illuminate\Database\QueryException SQLSTATE[HY000]: General error: 1
table recipes has no column named amount (SQL: insert into "recipes"
("image", "title", "servings", "ingredients", "amount",
"instructions", "user_id", "updated_at", "created_at") values
(uploads/U7lIutRFmbpyDz6EOUaExPGh5nYHElXZHcJv56CT.jpeg, pasta recipe,
4, pasta, 50g, cook it, 9, 2020-03-04 12:23:16, 2020-03-04 12:23:16))
It stores the image ok but nothing else.
Not sure on how to get the other fields to store either.
Below is the controller for recipes
enter image description here
Any help is much appreciated!
When it come to migrations, there's a general rule you should follow: Don't modify migrations after they have been run, unless you have the specific intent of re-running that migration. Generally, this requires a refresh of your database, and truncation of data.
You should make a new migration, like add_amount_to_recipies.php, which has the sole purpose of adding this new column in public function up(), and removing it in public function down():
public function up(){
Schema::table('recipies', function($table) {
$table->string('amount');
});
}
public function down(){
Schema::table('recipies', function($table) {
$table->dropColumn('amount');
});
}
Then, run php artisan migrate. This will add the column to the table without modifying the existing data.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I plan on having a massive JSON, ~20MB, and I am creating a React Native App using the JSON. I want to have the app:
Download only the changes to the JSON.
or at least
Download only if changes have been made (which will be less than once a month).
If there is something better than Firebase I would be fine switching over to that.
I had the same issue, a huge JSON object which change once a week. the way that I solved this issue is as following
lets say that we have an object O ~20MB
I created in my firebase db the object data = {raw: O, update: Date()}
on the client side I checked /data/update and compare it to the user localStorage. if it changed I replaced the user`s localstorage object, otherwise skipped.
In this way you dont need to download the whole O only to fetch the date object
it looks like
const {update, raw} = localStorage.fetch('/data')
const last_update = firebase.fetch('/data/update')
if(update === last_update){return raw}
const new_raw = firebase.fetch('/data/raw')
localStorage.save('/data', {update: last_update, raw: new_raw})
return new_raw
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I am attempting to create a script or figure out a formula that will allow me to do the following.
I am a teacher and often have student use Google Forms for quizzes and different surveys. When grading it I normally split their email. Occasionally some students will have a number after their last name.
firstname.lastname#stu.county.stateschools.us
I would like to take their e-mail and convert it to the following format.
lastname, firstname
This would allow me to sort easily and put into gradebook much faster.
The current best route I know of to do this is to split via . , # then join the data I want.
This takes multiple different columns to complete my task that could very easily overwrite their data. I want this to all take place in one column and get rid of the extra information I do not need.
There are multiple ways to do that. I would probably start with the indexOf() "#"
slice() the string to get the "firstname.lastname"
Next, split() the string to separate the firstname and lastname
Now reverse() the order of ["firstname", "lastname"]
Finally, join() them back together
var email = "firstname.lastname#stu.county.stateschools.us";
var index = email.indexOf('#');
var name = email.slice(0, index).split('.').reverse().join(', ');
// Logs "The student name is: lastname, firstname"
Logger.log("The student name is: %s", name);
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
I am running the folliwing code:
trial = read.csv("trial.csv",
header = TRUE,
sep = ",",
na.string = "NA",
skip = 0,
strip.white = TRUE,
stringsAsFactors=FALSE
)
which I've successfully run for 3 previous datasets. No problem, I eventually merged them and did my stuff.
However, on this one I can't understand what's going on: the dataset doesn't open. I've tried to see which column was giving me the problem and it is the sixth
x<-trial[6]
which is the only numeric one. So i thought it was a conversion problem (the string one, even if I put the code in the import one.
But it is not this problem, since when I run
str(trial)
it gives me num, as it should.
It's been a week I've been trying to solve this apparently simple problem but I can't pull though.
EDIT2 The IMF dataset I0m using can be freely downloaded at this link. You need to register (free) to do the bulk download at the top right. I'm not sure if this is the right way to link a dataset, pls let me know.
When you download the dataset, just choose one country (e.g. Italy) and leave the option "all indicators".
EDIT. There is no shown error message.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
This is fairly interesting. Flash CS6 has suddenly lost the ability to iterate through objects and delete their values (which did work before)
Delete all values from object keys
for each(var key:String in ScoreKeep.scoreCard)
ScoreKeep.scoreCard[key] = 0;
The object (ScoreKeep.as)
static public var scoreCard:Object = {
"Fish":6, "Golfball":2, "Gloves":8, "Boot":4,
};
You can trace the object key. The value will still be there.
You are using it wrongly, it is not supposed to be for each but for. for each would take the value, not the key.
You also have a "," after the last prop in your object, I assume that's a typo (and should result in a compile-time error).
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm in the planing phase of the development of an mobile app and I need your help to decide wheather I should go with MySQL or MongoDB. First let me describe the data:
I have a set of Items (e.g. movies) that users will be able to browse and score in different ways. The total number of Items is approximately 20 000 and it will not grow or shrink.
Each user will be able to score each item (numerical value) and write a comment assigned to each item. I expect that the average user will score maybe 40 different items, but my hopes are higher!
The typcial queries will be
Give me all items that satisfies some criteria and let me browse them. Example: Give me all Thrillers produced in Europe during the 00s.
Give me all movies that a particular user has scored.
I would also like to do some server side calculations e.g. average score for each movie, and each time a user sumbits a new score for an item this average should be updated.
For MySQL I would have a database with 3 different tables for this (Items, Users, Scores) and for MongoDB I'm considering a database with 1 collection, like this:
{
"name":"Inception"
"year":2010
"director":"Christopher Nolan"
"scores" : [
{
"user_id": 1234
"scoreA" : 3,
"scoreB" : 5,
"scoreC" : 4,
},
{
"user_id": 1235
"scoreA" : 4,
"scoreB" : 3
},
}
{
"name":"Titanic"
"year":1997
"director":"James Cameron"
"scores" : [
{
"user_id": 1201
"scoreB" : 5,
"scoreC" : 5
},
{
"user_id": 1220
"scoreA" : 4,
"scoreC" : 5
},
}
...
Question: Given my use case, does it matter if I use MySQL or MongoDB?
Thank you in advance!
Go with a relational database like mysql, there is no need to use MongoDb here unless you just wanna try it out.
As generell advice use NoSQL (especially MongoDb) when you can't improve your RDMS anymore.
Also take a look at this wonderful presentation: http://www.thedotpost.com/2015/06/neha-narula-consistency-and-candy-crush