GoLang MongoCollection::createDBRef

request it (426)
GoLang replacement for PHP's MongoCollection::createDBRef [edit | history]



Do you know a GoLang replacement for PHP's MongoCollection::createDBRef? Write it!

PHP MongoCollection::createDBRef

PHP original manual for MongoCollection::createDBRef [ show | php.net ]

MongoCollection::createDBRef

(PECL mongo >=0.9.0)

MongoCollection::createDBRefCreates a database reference

Description

public array MongoCollection::createDBRef ( mixed $document_or_id )

Parameters

document_or_id

If an array or object is given, its _id field will be used as the reference ID. If a MongoId or scalar is given, it will be used as the reference ID.

Return Values

Returns a database reference array.

If an array without an _id field was provided as the document_or_id parameter, NULL will be returned.

Examples

Example #1 MongoCollection::createDBRef() example

<?php

$songs 
$db->songs;
$playlists $db->playlists;

// create a reference to a song
$manamana $songs->findOne(array('title' => 'Ma na ma na'));
$refToSong $songs->createDBRef($manamana);

// add the reference to my playlist
$playlists->update(array('username' => 'me'), array('$push' => array('songlist' => $refToSong)));

?>

See Also