couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Chambery <todd.chamb...@gmail.com>
Subject Re: storing objects with "function attributes"
Date Mon, 05 Apr 2010 00:04:47 GMT
As Nils and Adam have suggested, functions aren't part of JSON (something I
didn't know).

But as for why:  I have a lot of static objects that I want to handle data
in object-particular ways.  Eg.

{
    name: "Simple Weapon Proficiency",
    attack: function attack(attacks, weapon) {
       if(weapon.category == 'simple') {
          attacks.weapon_proficiency = 0;
       }
  return attacks;
    }
}

So there are a bunch of these, if the user has selected them (in the UI), I
ask each of the selected objects to modify the attack data however it's
supposed to.


On Sun, Apr 4, 2010 at 5:46 PM, Andrew Melo <andrew.melo@gmail.com> wrote:

> On Sun, Apr 4, 2010 at 4:29 PM, Todd Chambery <todd.chambery@gmail.com>
> wrote:
> > Hi all,
> >
> > I don't seem to be able to load "function attributes" of objects into
> > CouchDB:
> >
> > If I save
> > {
> >  name: "foo",
> >  func: function() {
> >     do();
> >     return;
> >  }
> > }
> >
> > func will not appear on the object.  If I change the func value to a
> string,
> > everything's cool.
> >
> > Can I store function attributes in CouchDB?
>
> What do you want the attributes to do?
>
> > Thanks,
> >
> > Todd
> >
>
>
>
> --
> --
> Andrew Melo
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message