On Wed, Aug 26, 2009 at 06:16:10PM -0400, Paul Davis wrote:
> I wouldn't say that. There's nothing that keeps your library from
> reserving a prefix for its internal use. You're free to use anything
> like $ or # or even use a _ suffix.
>
> > Is there any way I can define such a key, in order to interfere as
> > less as possible with library user's data? (i was thinking perhaps
> > externals some way to define some "reserved" keys?)
>
> The only two approaches would be convention and nesting. If you want
> to make sure you can store anything at all with the library, the only
> real answer is to create an object like {"_id": "foo", "user_data":
> ...} but just using another non-underscore prefix wouldn't be too far
> out of the question. Granted you might want to see if anyone else has
> nominated one for consistency across libraries.
I had a think about this a while back. I reckoned that $ was the best prefix
to use, since it keeps the Javascript use simple - no square brackets
required.
doc.$created
doc.$updated
etc
But right now I'm using a separate member for user data as Paul also
suggested:
{"created":...,
"updated":...,
"settings":{"user":"stuff"}
}