couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Deibert <mark.deib...@gmail.com>
Subject Re: Put method
Date Thu, 26 Sep 2013 17:13:02 GMT
Are you asking about creating new docs or updating existing? I believe
you're asking about "updating", so "yes" you need to GET the doc first,
make your changes, then PUT it back. If you're creating new then just POST
the new doc without any _id or _rev values. Filippo's point about the
"type" property is very, very important. You really need a type property on
all docs. The type property lets you use views sorta like tables. Not
really, but it mimics.


On Thu, Sep 26, 2013 at 1:06 PM, Filippo Fadda <
filippo.fadda@programmazione.it> wrote:

> Hello Ashraf,
>
> in CouchDB doesn't exist the concept of table or entity, as you can find
> in the entity relational model. Everything is a document in CouchDB, that
> means both student and message are documents. Here you have two different
> document types: student and message. So, in your model, you have to add a
> new property called 'type' to distinguish between a student and a message.
> You don't need to GET the student, you just need to store a new document
> to save your message for him.
>
> Here the student document structure:
>
>         _id
>         _rev
>         type: 'student'
>         name
>         age
>
> Here the message document structure:
>
>         _id
>         _rev
>         type: 'message'
>         senderId
>         recipientId
>         title
>         body
>
> I think you can understand the meaning of each property yourself.
>
> -Filippo
>
> On Sep 26, 2013, at 6:48 PM, Ashraf Janan wrote:
>
> > Hi,
> > Please :
> > I have a document field :  Student with :_id, _rev , name: "Tom" , age :
> "37"
> > and i want to send message to Tom
> >
> > * Can do please check if my steps are correct ?
> >
> > 1- i must to use Get method to get  Tom document
> > 2- then i will use Put method to send a message , in this case must i
> have the _id,_rev,name,age + message
> >     in the JSON form of that student.
> >
> > * If i have the _id only for a student Tom,
> >   Can i send a message to Tom direct?
> >
> > * Why i need to get all the fields in the Document Student to send a
> message ?
> >
> > Best regards
> > Ashraf
>
>

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