ReferenceError: createParents is not defined


#1

When i use the following below code i get an error "ReferenceError: createParents is not defined"

const addPhoneToContact = (bucket,contact_id,phone)=>{
return new Promise((resolve,reject)=>{
bucket.mutateIn(contact_id)
        .arrayAppend('phone',phone, createParents)
        .execute((err, result)=>{
  if(err) return reject(err);
  return resolve(result);
});
});
}

what am i missing so the array append will create parent if it does not exist. Also where can i find nodeJs
specific docs as the samples in nodeJs is python which is diffrent syntax


#2

Hey @makeawish,

You should pass createParents as an options block with value true, for instance:

bucket
  .mutateIn(contact_id)
  .arrayAppend('phone', phone, {createParents: true})
  ...

Cheers, Brett


#3

Thanks, that worked. is there any where actual docs for NodeJS or does one have to guess or ask for all functions which are a bit off mainstream.


#4

Hey @makeawish,

You can find the API reference here:
http://docs.couchbase.com/sdk-api/couchbase-node-client-2.6.0/MutateInBuilder.html#arrayAppend

P.S. What do you mean by ‘a bit off mainstream’? We are always looking to improve the SDKs, so it would be wonderful to get your opinion here!

Cheers, Brett


#5

I think it would be much more helpful with only having nodeJS samples in the nodeJS guide not mixed java, php and python as syntax varries from language. Also most google searches go back to main page instead to references as links broken,