display of some element of a collection in mongodb - mongodb
I have mongodb collection and i need to extract just only all products with their title and price.
My collection data :
{"orderid":"c3e15faf-e338-4ed5-9bbb-bbcd15295fd7","Id_cust":"10995116278711","Id_date":"91","TotalPrice":1933.53,"Orderline":[{"productId":"4165","asin":"B005G2G2SQ","title":"ESEE-6 Plain Black Blade With Grey Removable Lined Micarta Handles 1095 Carbon Steel 57-Rc","price":140.05,"brand":"Fila_(company)"},{"productId":"5916","asin":"B001CJ2LQ4","title":"Aimpoint M4s 2 Minute of Angle QRP2 CompM4 Sight with Mount","price":804.95,"brand":"Atletica"},{"productId":"7779","asin":"B003DO5L3G","title":"Lee Precision Load Master 223 Remington Reloading Rifle Kit (Red)","price":249.26,"brand":"BURRDA"},{"productId":"2722","asin":"B0017U1MJU","title":"Casio Mens PAW1500-1V Pathfinder Multi-Band Solar Atomic Ultimate Watch","price":190.27,"brand":"Reebok"},{"productId":"52","asin":"B007SYGLZO","title":"Armasight Spark CORE Multi-Purpose Night Vision Monocular","price":549.0,"brand":"Signia_(sportswear)"}],"Livreur":{"Id_livreur":"91bcee9f-8896-4e18-a24c-a8e86b97b3a1","Nom":"Tyson Anderson","gender":"Male","phone":"7-458-665-3444"}},
{"orderid":"35b26e6d-e450-4edc-9071-306cea10a083","Id_cust":"10995116278711","Id_date":"249","TotalPrice":1540.91,"Orderline":[{"productId":"1978","asin":"B001CZBMRC","title":"Benchmade Osborne Design Rift Knife","price":178.5,"brand":"CCM_(ice_hockey)"},{"productId":"857","asin":"B004IIKA2I","title":"Barnett Quad 400 Crossbow Package (Quiver 3 - 22-Inch Arrows and 4x32mm Scope)","price":354.99,"brand":"Fischer_(company)"},{"productId":"8362","asin":"B00635GTTW","title":"Schwinn IC2 Indoor Cycling Exercise Bike","price":422.49,"brand":"Admiral_Sportswear"},{"productId":"216","asin":"B000GKN45C","title":"Swagman XTC-4 Cross-Country 4-Bike Hitch Mount Rack (2-Inch Receiver Hitch)","price":349.99,"brand":"Elfin_Sports_Cars"},{"productId":"7766","asin":"B000KKEPJ2","title":"Lyman Reloading Press T-Mag Turret Press","price":234.94,"brand":"BURRDA"}],"Livreur":{"Id_livreur":"48d64c09-7a63-4fca-815a-a96921a82ee7","Nom":"Abdul Coll","gender":"Male","phone":"1-273-204-4721"}},
{"orderid":"ffaec62e-9875-42af-8789-0a97eabe77e4","Id_cust":"10995116278711","Id_date":"67","TotalPrice":1058.41,"Orderline":[{"productId":"2675","asin":"B00BPRM2O4","title":"Large Exercise Mat Large Workout Mat With A Unique Fabric Finish That Provides Excellent Traction And Floor Protection. Can Be Used In Conjunction With The Square36 YOGA Mat. The Square36 CARDIO Mat - The BIG Exercise Mat- Step Into the Square.","price":159.99,"brand":"Reebok"},{"productId":"1380","asin":"B000EQCVQ6","title":"Eureka! Apex 2XT Two-Person Tent","price":175.16,"brand":"Topper_(sports)"},{"productId":"9665","asin":"B004H4VSI8","title":"IRONMAN HIGH CAPACITY GRAVITY 3000 INVERSION TABLE","price":239.8,"brand":"Wilson_Sporting_Goods"},{"productId":"7603","asin":"B0017SC9H6","title":"Zero Tolerance Combat Folding Knife","price":199.0,"brand":"Tramontana_(sports_car)"},{"productId":"887","asin":"B00BCLL8C0","title":"SportRack SR7018 Vista XL Rear Opening Cargo Box 18-Cubic Feet","price":284.46,"brand":"Fischer_(company)"}],"Livreur":{"Id_livreur":"7548ac7b-5bf7-4c5a-a80d-5390b73b9b90","Nom":"Henry Wilde","gender":"Male","phone":"3-624-033-5243"}},
{"orderid":"125e7887-c41d-4a5a-aa6b-d2a3679d58e7","Id_cust":"10995116278711","Id_date":"477","TotalPrice":1624.98,"Orderline":[{"productId":"6250","asin":"B005DYQ9V2","title":"Invicta Men s 1463 Reserve Collection Chronograph Silver Dial Stainless Steel Watch","price":199.95,"brand":"Keuka_(brand)"},{"productId":"1138","asin":"B000AMRN12","title":"Stamina AeroPilates Reformer with Free-Form Cardio Rebounder","price":449.0,"brand":"Topper_(sports)"},{"productId":"7575","asin":"B005D7FXMA","title":"Cygolite Expilion 400 Usb Rechargeable Headlight with Quick Release Li-Ion Battery Stick and Wall Charger","price":113.99,"brand":"Derbi"},{"productId":"6529","asin":"B005Z2CYX4","title":"Zero Tolerance ZT0550 Hinderer Design Folding Knife","price":160.0,"brand":"CA_Sports"},{"productId":"7125","asin":"B007INYN6O","title":"Barnett Zombie 350 CRT Crossbow","price":702.04,"brand":"Elan_Snowboards"}],"Livreur":{"Id_livreur":"a1060a87-fdff-4acc-b728-c805b72b0740","Nom":"Percy Thornton","gender":"Male","phone":"5-744-522-0782"}},
{"orderid":"b259eafc-2f47-47dc-927b-5b6d6edbba1d","Id_cust":"10995116278711","Id_date":"617","TotalPrice":1484.76,"Orderline":[{"productId":"7667","asin":"B008W1TUAK","title":"MAGPUL ACS CARB STOCK MIL-SPEC BLACK","price":98.99,"brand":"POC_Sports"},{"productId":"6406","asin":"B001CJX50K","title":"Kinetic Rock n Roll Trainer w/Road Resistance Unit","price":389.99,"brand":"MYLAPS_Sports_Timing"},{"productId":"1883","asin":"B000O8Z7TW","title":"KNEX Education - Exploring Machines","price":126.79,"brand":"TRYMAX"},{"productId":"4158","asin":"B003AQKQAA","title":"Vortex Viper PST 6-24x50 Rifle PST-624S1-M","price":749.0,"brand":"Fila_(company)"},{"productId":"7578","asin":"B00D43A93I","title":"Under Armour Hammer 8600014-4808 Polarized Wrap Sunglasses","price":119.99,"brand":"Derbi"}],"Livreur":{"Id_livreur":"eb135eef-7ee2-4d90-b073-cbd4570935b3","Nom":"Violet Adler","gender":"Female","phone":"5-466-075-2676"}},
{"orderid":"b5755c1e-fc3f-4481-a175-edfc82290ea5","Id_cust":"10995116278711","Id_date":"208","TotalPrice":2487.71,"Orderline":[{"productId":"965","asin":"B000O3AVNY","title":"Advanced Elements AdvancedFrame Expedition Kayak","price":599.99,"brand":"Donnay_(sports)"},{"productId":"6888","asin":"B0029KL3S2","title":"Precor 240i Commercial Series StretchTrainer","price":704.2,"brand":"Elan_(company)"},{"productId":"6439","asin":"B004PJ1J4S","title":"Invicta Men s 6566 Subaqua Noma IV Collection Chronograph Black Polyurethane Watch","price":340.65,"brand":"MYLAPS_Sports_Timing"},{"productId":"9503","asin":"B0034PXYRY","title":"Eotech EXPS3-0 Holographic Weapon Site","price":606.92,"brand":"EA_Sports"},{"productId":"7740","asin":"B00271ERVI","title":"Crimson Trace Lasergrip for Ruger Lcr","price":235.95,"brand":"BURRDA"}],"Livreur":{"Id_livreur":"c75a672e-37cf-498e-8bf9-8dae7857165f","Nom":"Renee Eyres","gender":"Female","phone":"6-311-624-4031"}},
{"orderid":"8a129f4e-e736-4919-9a22-c98373f1df3b","Id_cust":"10995116278711","Id_date":"390","TotalPrice":1233.67,"Orderline":[{"productId":"1929","asin":"B004P4HH8U","title":"Barnett Ghost 350 CRT Crossbow Package (Quiver 3 - 20-Inch Arrows and Illuminated 3x32mm Scope)","price":509.99,"brand":"TRYMAX"},{"productId":"2940","asin":"B004IIZVQ8","title":"Barnett Wildcat C5 Crossbow Package (Quiver 3 - 20-Inch Arrows and Premium Red Dot Sight)","price":342.99,"brand":"Volkl"},{"productId":"3174","asin":"B006U0YZPA","title":"Bushnell X-8 6MP Trail Camera with Night Vision and Field Scan","price":136.94,"brand":"Daei_Sport"},{"productId":"6527","asin":"B003MA1SSI","title":"Sadlak Industries M14 National Match Spring Guide","price":40.75,"brand":"CA_Sports"},{"productId":"1759","asin":"B007L4ZGXE","title":"Zero Tolerance ZT0560 Hinderer Design Black Folding Knife","price":203.0,"brand":"Olympikus"}],"Livreur":{"Id_livreur":"2ccb39c1-5c1a-46d8-b394-fc887bd4cecd","Nom":"Faith Flanders","gender":"Female","phone":"2-586-775-3278"}},
{"orderid":"bb671476-5f67-414a-9b84-77498b05f0bd","Id_cust":"10995116278711","Id_date":"205","TotalPrice":1601.81,"Orderline":[{"productId":"810","asin":"B009K28INA","title":"Schwinn 425 Elliptical Trainer (2013)","price":599.99,"brand":"Fischer_(company)"},{"productId":"6802","asin":"B000WY8ZHO","title":"Luminox Men s Navy Seal ColorMark Watch 3051","price":229.09,"brand":"Onda_(sportswear)"},{"productId":"3178","asin":"B007O5B0LC","title":"Weslo Cadence G 5.9 Treadmill","price":351.0,"brand":"Daei_Sport"},{"productId":"2126","asin":"B0025YCYK8","title":"Spyderco Temperence 2 Canvas Micarta Plain Edge Knife","price":207.72,"brand":"Li-Ning"},{"productId":"6736","asin":"B002QWB8HY","title":"CamelBak BFM 3L Backpack","price":214.01,"brand":"Onda_(sportswear)"}],"Livreur":{"Id_livreur":"629b2edd-8bd4-4d50-8e63-33f4904ffd2c","Nom":"Stephanie Garcia","gender":"Female","phone":"6-618-288-6820"}},
{"orderid":"d3016947-f478-4782-941d-37132482a10a","Id_cust":"10995116278711","Id_date":"694","TotalPrice":1534.78,"Orderline":[{"productId":"3029","asin":"B00AJK9CW8","title":"Seiko Men s SRP307 Classic Automatic Dive Watch","price":192.87,"brand":"Kettler"},{"productId":"2964","asin":"B004V956P0","title":"Crosman Optimus Break Barrel Air Rifle (.177)","price":91.98,"brand":"Volkl"},{"productId":"4115","asin":"B003UNZHNY","title":"Schwinn A10 Upright Exercise Bike (2011)","price":199.99,"brand":"Fila_(company)"},{"productId":"6853","asin":"B0081MPIBA","title":"ETEK4 - Planet Eclipse Etek 4 LT / AM Paintball Guns","price":499.95,"brand":"Elan_(company)"},{"productId":"893","asin":"B001AS697O","title":"Bowflex PR1000 Home Gym","price":549.99,"brand":"Fischer_(company)"}],"Livreur":{"Id_livreur":"787192a7-8417-44a9-a5bb-dd9060afd524","Nom":"Isla Denton","gender":"Female","phone":"1-260-416-8800"}},
{"orderid":"30dd4a79-4dac-4043-8fbc-e746e78aced3","Id_cust":"10995116278711","Id_date":"702","TotalPrice":1329.04,"Orderline":[{"productId":"2726","asin":"B005SSWKMK","title":"Casio Men s PRW2500T-7CR Pathfinder Triple Sensor Tough Solar Digital Multi-Function Titanium Pathfinder Casual Watch","price":266.12,"brand":"Reebok"},{"productId":"6563","asin":"B0014NDXGA","title":"Bushnell Tour V2 Standard Edition Golf Laser Rangefinder","price":290.06,"brand":"Onda_(sportswear)"},{"productId":"4856","asin":"B001QD48GC","title":"FreeForm Hideaway Home Gym","price":641.93,"brand":"ASICS"},{"productId":"7653","asin":"B007ZNUG9K","title":"Blackhawk Black TraverseTrack Bipod - 10 - BH71BP10BK","price":50.98,"brand":"POC_Sports"},{"productId":"4166","asin":"B00AJT98OQ","title":"Universal Brass Catcher","price":79.95,"brand":"Fila_(company)"}],"Livreur":{"Id_livreur":"5acb6f8a-fb71-4b32-b40d-fde782d70600","Nom":"Belinda Marshall","gender":"Female","phone":"6-671-643-4273"}},
2- I want to calculate the number of all products ?
You can do it using .find():
db.orders.find({}, { 'Orderline.title': 1, 'Orderline.price': 1 })
Or you can do it using .projection() method after you fetch all the orders:
db.orders.find({}).projection({ 'Orderline.title': 1, 'Orderline.price': 1 })
Related
Trying to grab text from Generator in Powershell
I'm trying to use a Invoke-WebRequest -Uri https://www.lingerandlook.com/Names/StreetNameGenerator.htm |Select-Object yadda yadda to get a 3 word "sweet street name" from this site but I am unable to get it to get the right content or find the text when parsing the site. Can someone help me? Tried to find content on page in powershell but am unable to see the text generated only that it's spanid is $name. I'm generally new to powershell so unsure of how to move forward
In this particular case, you can get the list of generated street names from that site like this: $request = Invoke-WebRequest -Uri 'https://www.lingerandlook.com/Names/StreetNameGenerator.htm' $table = #($request.ParsedHtml.getElementsByClassName('tlist'))[0] $table.deleteRow(0) # remove the top table row 'If you want to invent your own name...' # next move through all the data rows and join the content of its cells to form a street name $streetList = foreach ($row in $table.Rows) { ($row.Cells | ForEach-Object { $_.innerText }) -join ' ' } # output the resulting array to console $streetList # or save it to some file $streetList | Set-Content -Path 'X:\Somewhere\StreetList.txt' Result Amber Acorn Acres Auburn Anchor Alcove Bent Apple Arbor Big Autumn Avenue Birch Axe Bank Blue Barn Bayou Bright Beacon Bend Broad Bear Bluff Burning Beaver Byway Calm Berry Canyon Cinder Bird Chase Clear Blossom Circle Cold Bluff Corner Colonial Branch Court Cool Bridge Cove Cotton Brook Crest Cozy Butterfly Cut Crimson Butternut Dale Crystal Castle Dell Dewy Chestnut Drive Dusty Cider Edge Easy Cloud Estates Emerald Cottage Falls Fallen Creek Farms Foggy Crow Field Gentle Dale Flats Golden Deer Gardens Grand Diamond Gate Green Dove Glade Happy Elk Glen Harvest Elm Grove Hazy Embers Haven Heather Fawn Heights Hidden Feather Highlands High Flower Hollow Honey Forest Isle Hush Fox Jetty Indian Gate Journey Iron Goat Knoll Ivory Goose Lace Jagged Grove Lagoon Lazy Harbor Landing Little Hickory Lane Lone Hills Ledge Lonely Holly Manor Long Horse Meadow Lost Island Mews Merry Lake Niche Middle Lamb Nook Misty Leaf Orchard Noble Log Pace Old Maple Park Orange Mill Pass Pearl Mountain Path Pied Nectar Pike Pleasant Nest Place Pretty Nut Point Quaint Oak Promenade Quaking Panda Quay Quiet Peach Race Red Pebble Ramble Rocky Pine Ridge Rose Pioneer Road Rough Pond Round Round Pony Rove Rustic Prairie Run Sandy Pumpkin Saunter Shady Quail Shoal Silent Rabbit Stead Silver Rise Street Sleepy River Stroll Small Robin Summit Square Rock Swale Still Shadow Terrace Stony Sky Trace Strong Snake Trail Sunny Spring Trek Sweet Squirrel Turn Tawny Stone Twist Tender Swan Vale Thunder Timber Valley Turning Treasure View Twin Turtle Villa Umber View Vista Velvet Wagon Wander White Willow Way Windy Zephyr Woods
Making `ScrewJoint` more compliant to the manipulator
I am working on a simulation, which contains: a bolt, welded uprightly to the world a nut, connected to the bolt via ScrewJoint. The mass of a nut set to 0.02 kg, the inertia is a diagonal 1.1e-9 *I. This is configured via a .sdf file. an iiwa manipulator, which is beside a point for now. The problem is that the nut is very hard to manipulate and I cannot find a parameter to adjust, which could've made it more lifelike. To be more specific: I measure the ability of force, applied tangentially in a horizontal plane to the nut, to cause the screwing motion of a joint, that joins the nut with a bolt I'd like to have greater amount of motion at lower forces, and so far I am failing to achieve that My interest in doing this is not idle; I am interested in more complicated simulations, which are also failing when iiwa is coming in a contact with this same joint; I've asked about those here and here. (Both answered partially). To sum up those here: when manipulator grips the nut, the nut fights the screwing in such a manner, that the schunk gripper is forced to unclasp and iiwa is thrown off-track, but the nut remains stationary. I attach below two simpler experiments to better illustrate the issue: 1. Applying tangentially in a horizontal plane 200N force using ExternallyAppliedSpatialForce. Graph notation: (here as well as below) The left graph contains linear quantities (m, m/s, etc) along world's Z axis, the right graph contains angular quantities (in degrees, deg, deg/s, etc) around world's Z axis. The legend entries with a trailing apostrophe use the secondary Y-axis scale; other legend entries use the primary Y-axis scale. Experiment summary: This works as expected, 200 N is enough to make the nut spin on a bolt, resulting in the nut traveling vertically along the bolt for just under 1 centimeter, and spinning for over 90 degrees. Note: the externally applied force does not show up on my graph. 2. Applying tangentially in a horizontal plane force using iiwa and a simple position controller. Experiment summary: The force here is approximately the same as before: 70N along tz, but higher (170N) in tx and ty, though it is applied now only for a brief moment. The nut travels just a few degrees or hundredth fractions of centimeter. The video of this unsuccessful interaction is below, the contact forces are visualized using ContactVisualizer. Please advise me on how to make this screw_joint more compliant? I've tried varying mass and inertia of the nut (different up to the orders of magnitude) in these experiments, this seems to scale the contact forces, but does not affect acceleration or velocity of the nut after contact.
I like your experiment using ExternallyAppliedSpatialForce to get an idea of scales, though TBH I didn't quite get the details of this setup. Things that caught my eye though are about scales, which you can estimate with pen and paper: Your inertia is 1e-9 kg⋅m²?! Judging from your interaction with the iiwa I estimated a radius of 1cm and with that you'd get 2e-6 kg⋅m², three orders of magnitude larger. A force of 200 N on a 20 grams nut would cause an acceleration of 10000 m/s². As a reference, that's 1000 times the acceleration of Earth's gravity! Are these numbers correct? Also, if you happen to have fast interactions (do you?), you might want to estimate a time step that makes sense for your application. Hopefully this helps!
A good thing is that I've fixed it; a bad thing: I don't understand the fix. Let's restate a problem that I was tacking: a manipulated object reacted quite predictably to the ExternallyAppliedSpatialForce, but couldn't be moved via the contact with the manipulator. What was done: I've update drake from 2f340192a9dc79110410faf8a6d54a8615ddca92 (circa 22 Aug, 2022) to 42448c0af1b39f0c46f760e7ae37d77097689ad3 (circa 3 Nov, 2022) After the update, my experimental setup broke down with assertion Actuation input port for model instance ... must be connected. [Similar to the issue raised in this question.]. My fix was like that: bolt_n_nut_ = internal::AddAndWeldModelFrom(sdf_path, "nut_and_bolt", plant_->world_frame(), "bolt", X_WC, plant_); then later in ManipulationStation::Finalize: auto zero_torque = builder.template AddSystem<systems::ConstantVectorSource<double>>( Eigen::VectorXd::Zero(1)); builder.Connect(zero_torque->get_output_port(), plant_->get_actuation_input_port(bolt_n_nut_)); With changes above, a manipuland began to interact with the manipulator: Things to note in graphs: the distance the manipuland has moved grew from fractions of millimeter up to tens of centimeters. The video presents that a nut became manipulable. This interaction violates the constraints of the ScrewJoint, i.e. the manipuland moves along it's axis without as much rotation
Planet tilts and rotations.
We are building an Astronomical clock that tracks the planet and moon locations in the Galilain solar system ( planets out to Saturn And moons do earth and 4 moons of Jupiter. Think if an orrery that acuately tracks time. The clock can move to different epoch and Can move through the 12 astronomical ages. It’s 8ft in diameter, hangs from the ceiling, 24 stepper motors drive the rotations and tilts of the planets, 18.6 year moon cycle etc. We plan to use PyEphem to identify locations of planets. We need additional data and was wondering if python can provide this data. We need the rotation and tilt of planet (earth mars Saturn). And we need tie rotation so the part of the planet that faces the sun. Lastly we need to Jupiter’s 4 major moons location over the planet. Does PyEphem support these addition items and if not is there any advice you can provide us. W
Details of what PyEphem supports are available from the PyEphem website which provides detailed, searchable documentation. This is very standard for software libraries. I am not being disingenuous when I advise you to RTFM - this is definitive material. Google and Bing should be your next port of call, especially since you have clearly defined search terms.
Alas, PyEphem does not include any models of planetary rotation, no — so the lack of any mention of it in the documentation is not an omission but the lack of that feature in the underlying libastro library.
Modeling Contact in Abaqus
I have simulated a 2D model in Abaqus which indicates 2 main part, first a sector that represent as wheel and, second a rectangular that represent rail. the wheel and rail are in contact and wheel should rotate and move from left to right. there is a vertical small crack in middle of the rail to studying the result of contact on fracture mechanics. my model has been completed, and in the 1/10 of total time good result has been achieved but after that the stress distribution is completely wrong and although the contact seems to exist, the stress is almost zero. Any guide, comment or advice would be appreciated. thank you
MATLAB / SIMULINK: Simulate filling and emptying of a river
Background: A river has a non-constant cross-section. Under standard conditions, the water level amounts h_Std (see figure below). As it begins to rain, the water level rises until it is equal to h_Rain (see figure below) After the rain stops, the water level decreases back to the standard water level. As one can see from the diagrams, the relation between water level and volume is non-constant. However, the function can be desribed mathematically and is known for my particular cross-section of the river. Problem description: I want to simulate the water level of the river over time in case of raining. The rain is represented by an signal which can either be 0 (not raining) or 1 (raining) (see red curve in figure below): The dark-blue parts of the lower diagram are nonlinear and represents the section between h_Std and h_Rain from the diagrams above. The time for completly filling the river is known (t_Fill). Generaly spoken, I want to activate an user-defined function (in my case the relation between the amount of water / rain and the water level of the river) triggered by an external signal (in my case represented by the "rain"-signal). How can I obtain such a function (either with a piece of Matlab-Code oder with Simulink blocks)?
There are several ways this could be done, one of which is to use enabled subsystems to process the raining and not raining phases. You'd need to change the contents of the 2 subsystems below to reflect your exact height profile in the 2 regions.