incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavan Kumar <tvpa...@gmail.com>
Subject Re: storing objects with "function attributes"
Date Mon, 05 Apr 2010 12:25:21 GMT
eval() + jquery 'apply' is the probably one way to get the job done.   As
Nils mentioned you can keep your function as a plain text member in JSON,
retrive and use eval and apply to call it dynamically at the client side
browser.

Pavan

On Mon, Apr 5, 2010 at 2:02 PM, Nils Breunese <N.Breunese@vpro.nl> wrote:

> I guess you'll either need to serialize the logic code to be able to store
> this in JSON and unserialize after loading the document, or separate the
> logic from the data.
>
> Nils Breunese.
> ________________________________________
> Van: Todd Chambery [todd.chambery@gmail.com]
> Verzonden: maandag 5 april 2010 2:04
> Aan: user@couchdb.apache.org
> Onderwerp: Re: storing objects with "function attributes"
>
> 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.
>
> De informatie vervat in deze  e-mail en meegezonden bijlagen is uitsluitend
> bedoeld voor gebruik door de geadresseerde en kan vertrouwelijke informatie
> bevatten. Openbaarmaking, vermenigvuldiging, verspreiding en/of verstrekking
> van deze informatie aan derden is voorbehouden aan geadresseerde. De VPRO
> staat niet in voor de juiste en volledige overbrenging van de inhoud van een
> verzonden e-mail, noch voor tijdige ontvangst daarvan.
>

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