1

How do I prevent an ObjectID form becoming primitive when passing in and out of Redis?

Parsing to JSON string? Thanks!

fancy
  • 48,619
  • 62
  • 153
  • 231

1 Answers1

0

You can either store your object as JSON string representation in simple string or use hash data structure. Node.js node_redis module offers friendlier hash commands which may be useful. There is also a library for storing objects in redis called nohm which is based on object-hash mapping library ohm.

yojimbo87
  • 65,684
  • 25
  • 123
  • 131
  • Using JSON.stringify() and JSON.parse() I don't think a hash structure helps here but maybe I'm doing it wrong? – fancy Sep 19 '11 at 16:35
  • @fancy: Try to look at [this](http://stackoverflow.com/questions/5252456/storing-object-properties-in-redis) question and answer. Maybe it will help you. – yojimbo87 Sep 19 '11 at 18:03
  • yea, I use hashes like that. I still need to stringify and parse things to have them return as proper objects outside of redis. – fancy Sep 19 '11 at 18:35