labpack/databases/couchbase.py
def create(self, doc_details):

        '''
            a method to create a new document in the collection

        :param doc_details: dictionary with document details and user id value
        :return: dictionary with document details and _id and _rev values
        '''
        
        # https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/document/post__db___doc_

        title = '%s.create' % self.__class__.__name__

    # validate input
        if self.model:
            doc_details = self.model.validate(doc_details, path_to_root='', object_title='%s(doc_details={...}' % title)

    # define request fields
        from copy import deepcopy
        new_record = deepcopy(doc_details)
        url = self.bucket_url + '/'

    # send request and construct output
        response = requests.post(url, json=new_record)
        if response.status_code not in (200, 201):
            response = response.json()
            raise Exception('%s() error: %s' % (title, response))
        response = response.json()
        new_record['_id'] = response['id']
        new_record['_rev'] = response['rev']
    
        return new_record

            a method to create a new document in the collection

        :param doc_details: dictionary with document details and user id value
        :return: dictionary with document details and _id and _rev values
        
a method to create a new document in the collection
a method to create a new document in the collection
def create(self, doc_details):
        title = '%s.create' % self.__class__.__name__
        if self.model:
            doc_details = self.model.validate(doc_details, path_to_root='', object_title='%s(doc_details={...}' % title)
        from copy import deepcopy
        new_record = deepcopy(doc_details)
        url = self.bucket_url + '/'
        response = requests.post(url, json=new_record)
        if response.status_code not in (200, 201):
            response = response.json()
            raise Exception('%s() error: %s' % (title, response))
        response = response.json()
        new_record['_id'] = response['id']
        new_record['_rev'] = response['rev']
        return new_record
def create ( self , doc_details ) : title = '%s.create' % self . __class__ . __name__ if self . model : doc_details = self . model . validate ( doc_details , path_to_root = '' , object_title = '%s(doc_details={...}' % title ) from copy import deepcopy new_record = deepcopy ( doc_details ) url = self . bucket_url + '/' response = requests . post ( url , json = new_record ) if response . status_code not in ( 200 , 201 ) : response = response . json ( ) raise Exception ( '%s() error: %s' % ( title , response ) ) response = response . json ( ) new_record [ '_id' ] = response [ 'id' ] new_record [ '_rev' ] = response [ 'rev' ] return new_record
a method to create a new document in the collection
a method to create a new document in the collection
'''
            a method to create a new document in the collection

        :param doc_details: dictionary with document details and user id value
        :return: dictionary with document details and _id and _rev values
        ''' # https://developer.couchbase.com/documentation/mobile/1.5/references/sync-gateway/admin-rest-api/index.html#/document/post__db___doc_ # validate input # define request fields # send request and construct output
dictionary with document details and _id and _rev values
dictionary with document details and _id and _rev values
self
doc_details
dictionary with document details and user id value
dictionary with document details and user id value