thefootballguy Posted June 21, 2016 Share Posted June 21, 2016 I am trying to save sprite data to a database and being able to change it later. but I am having trouble figuring out how to implement this. (preferable redis) db.hmset("graphics:dude", JSON.stringify(dudeData)); var dudeData = [ '.......3.....', '......333....', '....5343335..', '...332333333.', '..33333333333', '..37773337773', '..38587778583', '..38588888583', '..37888888873', '...333333333.', '.F....5556...', '3E34.6757.6..', '.E.55.666.5..', '......777.5..', '.....6..7....', '.....7..7....' ]; Then use something like JSON.parse() to get the data back? Link to comment Share on other sites More sharing options...
VitaZheltyakov Posted June 21, 2016 Share Posted June 21, 2016 Use eval Link to comment Share on other sites More sharing options...
thefootballguy Posted June 21, 2016 Author Share Posted June 21, 2016 I am sorry I don't understand care to explain @VitaZheltyakov Link to comment Share on other sites More sharing options...
VitaZheltyakov Posted June 21, 2016 Share Posted June 21, 2016 4 hours ago, thefootballguy said: I am sorry I don't understand care to explain @VitaZheltyakov var dudeData = eval(data_from_db); Link to comment Share on other sites More sharing options...
thefootballguy Posted June 22, 2016 Author Share Posted June 22, 2016 Well thanks for the help @VitaZheltyakov but I finally figured out using it just using nodejs-redis examples. However, I don't know how to access the data OUTSIDE of nodejs main "app.js" file. If anyone can help, I will greatly appreciate it. http://stackoverflow.com/questions/37956668/how-to-access-string-data-from-redis-through-another-js-file-in-nodejs Link to comment Share on other sites More sharing options...
drhayes Posted June 22, 2016 Share Posted June 22, 2016 You can export the data just like you export functions, so that other files can require it. "module.exports.dudeData = ...", like that. Link to comment Share on other sites More sharing options...
Recommended Posts