def create_doc_mult(self, docs, object_ids=None, datastore_name=None):
        if type(docs) is not list:
            raise BadRequest("Invalid type for docs:%s" % type(docs))
        if object_ids and len(object_ids) != len(docs):
            raise BadRequest("Invalid object_ids")
        if not docs:
            return []
        log.debug('create_doc_mult(): create %s documents', len(docs))

        qual_ds_name = self._get_datastore_name(datastore_name)

        doc_obj_type = [self._get_obj_type(doc, self.profile) for doc in docs]
        all_obj_types = set(doc_obj_type)

        with self.pool.cursor(**self.cursor_args) as cur:
            # Need to make sure to first insert resources then associations for referential integrity
            for obj_type in sorted(all_obj_types, key=lambda x: OBJ_TYPE_PRECED.get(x, 10)):
                sb = StatementBuilder()
                docs_ot = [doc for (doc, doc_ot) in zip(docs, doc_obj_type) if doc_ot == obj_type]

                # Take the first document to determine the type of objects (resource, association, dir entry)
                extra_cols, table = self._get_extra_cols(docs_ot[0], qual_ds_name, self.profile)
                xcol = ""
                for col in extra_cols:
                    xcol += ", %s" % col
                sb.append("INSERT INTO "+table+" (id, rev, doc" + xcol + ") VALUES ")

                # Build a large statement
                for i, doc in enumerate(docs_ot):
                    object_id = object_ids[i] if object_ids else None
                    if "_id" not in doc:
                        object_id = object_id or self.get_unique_id()
                        doc["_id"] = object_id

                    doc["_rev"] = "1"
                    doc_json = json.dumps(doc)

                    if i>0:
                        sb.append(",")

                    sb.statement_args["id"+str(i)] = doc["_id"]
                    sb.statement_args["doc"+str(i)] = doc_json
                    xval = ""
                    for col in extra_cols:
                        valuename = col + str(i)
                        insert_expr = self._create_value_expression(col, doc, valuename, sb.statement_args, allow_null_values=True)
                        xval += insert_expr

                    sb.append("(%(id", str(i), ")s, 1, %(doc", str(i), ")s", xval, ")")

                try:
                    cur.execute(*sb.build())
                    if cur.rowcount != len(docs_ot):
                        log.warn("Number of objects created (%s) != objects given (%s) in %s", cur.rowcount, len(docs_ot), table)
                except IntegrityError as ie:
                    raise BadRequest("Some object already exists: %s" % ie)

        result_list = [(True, doc["_id"], doc["_rev"]) for doc in docs]

        return result_list
Creates a list of objects and returns 3-tuples of (Success, id, rev).
dataset/ETHPy150Open ooici/pyon/pyon/datastore/postgresql/base_store.py/PostgresDataStore.create_doc_mult