Beispiel #1
0
/**
 * Deletes all our known collections
 * 
 * @param MongoDB $db
 */
function zapDatabase(MongoDB $db)
{
    getComponentCollection($db)->drop();
    getManufacturerCollection($db)->drop();
}
Beispiel #2
0
 * not be useful for a frame, which will have a colour property.
 * 
 * Components can contain components too, if it is felt necessary. For example rather than
 * a bike->crank and bike->chain relationships, it may be cleaner to group them together in
 * a drivetrain subgroup, e.g. bike->drivetrain->crank, bike->drivetrain->chain, especially
 * if this drivetrain set is used in other bikes.
 */
// Load libraries
$root = __DIR__;
require_once $root . '/functions.php';
$m = new MongoClient();
// select a database and clear it
$db = $m->bikes;
zapDatabase($db);
// Let's create some component manufacturers
$manuCollection = getManufacturerCollection($db);
createManufacturer($manuCollection, "Haibike");
// Of the bike itself
createManufacturer($manuCollection, "Yamaha");
// Component manufacturers
createManufacturer($manuCollection, "Shimano");
createManufacturer($manuCollection, "Fox");
createManufacturer($manuCollection, "Selle Royal");
createManufacturer($manuCollection, "FSA");
// Let's create some components
$compCollection = getComponentCollection($db);
$ids = [];
$ids[] = createDocument($compCollection, "Battery 400Wh", ['watt-hours' => 400]);
$ids[] = createDocument($compCollection, "Motor", ['voltage' => 36, 'wattage' => 250, 'manufacturer' => getManufacturerId($manuCollection, 'yamaha'), 'list_price' => ['currency' => 'GBP', 'value' => 300]]);
$ids[] = createDocument($compCollection, "Haibike SDURO frame", ['material' => 'Aluminium', 'size_inches' => 27.5, 'description' => "6061, All MNT, 4-Link System, Yamaha-Interface, hydroforced tubes, 150mm", 'list_price' => ['currency' => 'GBP', 'value' => 400]]);
// Special group for the drivetrain