添加
$collection = (new MongoDB\Client)->test->users;
// 增加一条
$insertOneResult = $collection->insertOne([
'username' => 'admin',
'email' => '[email protected]',
'name' => 'Admin User',
]);
// 增加多条
$insertManyResult = $collection->insertMany([
[
'username' => 'admin',
'email' => '[email protected]',
'name' => 'Admin User',
],
[
'username' => 'test',
'email' => '[email protected]',
'name' => 'Test User',
],
]);