[DOCS-13692] $function examples seem overcomplicated Created: 09/Jun/20  Updated: 30/Oct/23  Due: 26/Jun/20  Resolved: 23/Jun/20

Status: Closed
Project: Documentation
Component/s: manual
Affects Version/s: None
Fix Version/s: Server_Docs_20231030

Type: Improvement Priority: Major - P3
Reporter: Charlie Swanson Assignee: Kay Kim (Inactive)
Resolution: Fixed Votes: 1
Labels: bite-sized, docs-query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:
Days since reply: 3 years, 33 weeks, 1 day ago
Epic Link: DOCSP-1769

 Description   

Description

On this page there are some examples which I think could be simplified. As the most striking example, I think

db.players.find( {$expr: { $function: {
      body: function(userFn, doc) { return userFn.call(doc); },
      args: [
         function() { return hex_md5(this.name) == "15b0a220baa16331e8d80e15367677ad" ; },
         "$$CURRENT"
      ],
      lang: "js"
} } } )

Could be simplified into just

db.players.find( {$expr: { $function: {
      body: function(name) { return hex_md5(name) == "15b0a220baa16331e8d80e15367677ad"; },
      args: [ "$name" ],
      lang: "js"
} } } )

Scope of changes

Impact to Other Docs

MVP (Work and Date)

Resources (Scope or Design Docs, Invision, etc.)



 Comments   
Comment by Githook User [ 23/Jun/20 ]

Author:

{'name': 'Kay Kim', 'email': 'kay.kim@10gen.com', 'username': 'kay-kim'}

Message: DOCS-13692: simplify $function example
Branch: master
https://github.com/mongodb/docs/commit/5cd7356f287f21d69cd715687927a63db1922652

Comment by Daniel Pasette (Inactive) [ 09/Jun/20 ]

this change would make the example a lot easier to parse. +1

Generated at Thu Feb 08 08:08:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.