Inserts an object
@param  array $doc Data
@param  callable $cb Optional. Callback called when response received
@param  array $params Optional. Params
@callback $cb ( )
@return MongoId
346091
public function insert($doc, $cb = null, $params = null)
    {
        return $this->pool->insert($this->name, $doc, $cb, $params);
    }
1102856
public function insertMany($documents, array $options = [])
    {
        $writeModel = new InsertMany($documents);
        $bulkWriteResult = $this->bulkWrite([$writeModel], $options);

        return new InsertManyResult($bulkWriteResult);
    }
1082862
public function loadDocument($documentId, \DmsLoaderParams $params)
  {
    $objDocument = $this->Database->prepare("SELECT d.*, CONCAT(m1.firstname, ' ', m1.lastname) AS upload_member_name, CONCAT(m2.firstname, ' ', m2.lastname) AS lastedit_member_name "
                        . "FROM tl_dms_documents d "
                        . "LEFT JOIN tl_member m1 ON m1.id = d.upload_member "
                        . "LEFT JOIN tl_member m2 ON m2.id = d.lastedit_member "
                        . "WHERE d.id = ?")
                    ->limit(1)
                    ->execute($documentId);
    
    $document = null;
    if ($objDocument->numRows)
    {
      $document = $this->buildDocument($objDocument);
      if ($params->loadCategory)
      {
        $document->category = $this->loadCategory($document->categoryId, $params);
      }
    }

    return $document;
  }
1342724
public function update($docId, $doc)
    {
        return $this->montage->request(
            'post',
            $this->montage->url('document-detail', $this->schema->name, $docId),
            ['body' => json_encode($doc)]
        );
    }
524003
public function put(array $arr_docs)
    {
        $obj_request = new IndexDocumentRequest();
        $obj_params = $this->prepareRequestParams($obj_request);

        // Other index specs: consistency, mode, name, namespace, source, version
        $obj_mapper = new Mapper();
        foreach($arr_docs as $obj_doc) {
            $obj_mapper->toGoogle($obj_doc, $obj_params->addDocument());
        }
        $this->execute('IndexDocument', $obj_request, new IndexDocumentResponse());
    }
13871
protected final function insert($data, $cb = null) {
        if ($cb && $cb instanceof \Closure) {
            $data = $cb ($data, $this);
        }
        if ($data) {
            $this->filterFields($data);
            if (method_exists($this, 'validateNewData')) {
                if (isset($this->_formData)) {
                    $this->validateNewData($this->_formData);
                } else {
                    $this->validateNewData($data);
                }
            }
            $sql = new InsertSQL($data);
            $sql->into($this->table)->setDialect($this->dialect);
            if ($this->autoIncrement) {
                $sql->autoField($this->primaryKey);
                $rst = $sql->newId();
            } else {
                $rst = $sql->exec(true);
            }
            if ($rst) {
                return $rst;
            } else {
                $this->checkSQL($sql);

                return false;
            }
        } else {
            $this->errors = '数据为空.';

            return false;
        }
    }
414333
public function createDBRef($collection, $document_or_id)
    {
        if ($document_or_id instanceof \MongoId) {
            $id = $document_or_id;
        } elseif (is_object($document_or_id)) {
            if (! isset($document_or_id->_id)) {
                $id = $document_or_id;
            } else {
                $id = $document_or_id->_id;
            }
        } elseif (is_array($document_or_id)) {
            if (! isset($document_or_id['_id'])) {
                return null;
            }

            $id = $document_or_id['_id'];
        } else {
            $id = $document_or_id;
        }

        return MongoDBRef::create($collection, $id);
    }
268020
function insertDoc (doc, qs0, callback0) {
      const req = { db: dbName, body: doc, method: 'POST' }

      let { opts, callback } = getCallback(qs0, callback0)

      if (typeof opts === 'string') {
        opts = { docName: opts }
      }

      if (opts) {
        if (opts.docName) {
          req.doc = opts.docName
          req.method = 'PUT'
          delete opts.docName
        }
        req.qs = opts
      }

      return relax(req, callback)
    }
23324
private function insertFile($record, array $options = [])
    {
        $record += [
            '_id' => new MongoId(),
            'uploadDate' => new MongoDate(),
            'chunkSize' => $this->defaultChunkSize,
        ];

        $result = $this->insert($record, $options);

        if (! $this->isOKResult($result)) {
            throw new \MongoException('error inserting file');
        }

        return $record;
    }
1292135
public function put($docs)
    {
        if($docs instanceof Document) {
            $this->obj_gateway->put([$docs]);
        } elseif (is_array($docs)) {
            $this->obj_gateway->put($docs);
        } else {
            throw new \InvalidArgumentException('Parameter must be one or more \Search\Document objects');
        }
    }
1121881
def insert_one(self, doc, *args, **kwargs):
        
        if self.table is None:
            self.build_table()

        if not isinstance(doc, dict):
            raise ValueError(u'"doc" must be a dict')

        _id = doc[u'_id'] = doc.get('_id') or generate_id()

        bypass_document_validation = kwargs.get('bypass_document_validation')
        if bypass_document_validation is True:
            # insert doc without validation of duplicated `_id`
            eid = self.table.insert(doc)
        else:
            existing = self.find_one({'_id': _id})
            if existing is None:
                eid = self.table.insert(doc)
            else:
                raise DuplicateKeyError(
                    u'_id:{0} already exists in collection:{1}'.format(
                        _id, self.tablename
                    )
                )

        return InsertOneResult(eid=eid, inserted_id=_id)
178108
protected function _insert(&$document) {

        $table           = $this->name;
        $document['_id'] = isset($document['_id']) ? $document['_id'] : createMongoDbLikeId();
        $data            = ['document' => \json_encode($document, JSON_UNESCAPED_UNICODE)];

        $fields = [];
        $values = [];

        foreach($data as $col=>$value){
            $fields[] = "`{$col}`";
            $values[] = (\is_null($value) ? 'NULL' : $this->database->connection->quote($value));
        }

        $fields = \implode(',', $fields);
        $values = \implode(',', $values);

        $sql = "INSERT INTO {$table} ({$fields}) VALUES ({$values})";
        $res = $this->database->connection->exec($sql);

        if ($res){
            return $this->database->connection->lastInsertId();
        } else {
            trigger_error('SQL Error: '.\implode(', ', $this->database->connection->errorInfo()).":\n".$sql);
            return false;
        }
    }
412720
def insert(collection_name, docs, check_keys, safe, last_error_args):
    
    data = __ZERO
    data += bson._make_c_string(collection_name)
    bson_data = "".join([bson.BSON.encode(doc, check_keys) for doc in docs])
    if not bson_data:
        raise InvalidOperation("cannot do an empty bulk insert")
    data += bson_data
    if safe:
        (_, insert_message) = __pack_message(2002, data)
        (request_id, error_message) = __last_error(last_error_args)
        return (request_id, insert_message + error_message)
    else:
        return __pack_message(2002, data)
459432
public function insertMany(array $documents)
    {
        foreach ($documents as $document) {
            $this->writeModels[] = [BulkWrite::INSERT_ONE => [$document]];
        }

        return $this;
    }
571635
def _insert(self, docs, ordered=True, check_keys=True,
                manipulate=False, write_concern=None, op_id=None,
                bypass_doc_val=False, session=None):
        """"""
        if isinstance(docs, abc.Mapping):
            return self._insert_one(
                docs, ordered, check_keys, manipulate, write_concern, op_id,
                bypass_doc_val, session)

        ids = []

        if manipulate:
            def gen():
                """Generator that applies SON manipulators to each document
                and adds _id if necessary.
                """
                _db = self.__database
                for doc in docs:
                    # Apply user-configured SON manipulators. This order of
                    # operations is required for backwards compatibility,
                    # see PYTHON-709.
                    doc = _db._apply_incoming_manipulators(doc, self)
                    if not (isinstance(doc, RawBSONDocument) or '_id' in doc):
                        doc['_id'] = ObjectId()

                    doc = _db._apply_incoming_copying_manipulators(doc, self)
                    ids.append(doc['_id'])
                    yield doc
        else:
            def gen():
                """Generator that only tracks existing _ids."""
                for doc in docs:
                    # Don't inflate RawBSONDocument by touching fields.
                    if not isinstance(doc, RawBSONDocument):
                        ids.append(doc.get('_id'))
                    yield doc

        write_concern = write_concern or self._write_concern_for(session)
        blk = _Bulk(self, ordered, bypass_doc_val)
        blk.ops = [(message._INSERT, doc) for doc in gen()]
        try:
            blk.execute(write_concern, session=session)
        except BulkWriteError as bwe:
            _raise_last_error(bwe.details)
        return ids
861786
def add_insert(self, document):
        
        validate_is_document_type("document", document)
        # Generate ObjectId client side.
        if not (isinstance(document, RawBSONDocument) or '_id' in document):
            document['_id'] = ObjectId()
        self.ops.append((_INSERT, document))
984477
def insert(self):
        """"""
        from mongoframes.queries import to_refs

        # Send insert signal
        signal('insert').send(self.__class__, frames=[self])

        # Prepare the document to be inserted
        document = to_refs(self._document)

        # Insert the document and update the Id
        self._id = self.get_collection().insert_one(document).inserted_id

        # Send inserted signal
        signal('inserted').send(self.__class__, frames=[self])