findOneAndUpdate returns with error “Query for sharded findAndModify must contain the shard key”

My query is a java script file that gets the variables from a caller bash script:

findOneAndUpdate({“id”: ObjectId(doc_id)}, {$set: { “attributes.StudentNo”: student_no + “” + epoch + “_” + curr_date } });

When I run the query I get this error:

2022-01-13T15:35:32.421+1100 E QUERY [js] uncaught exception:
Error: findAndModifyFailed failed: {
“ok” : 0,
“errmsg” : “Query for sharded findAndModify must contain the shard key”,
“code” : 61,
“codeName” : “ShardKeyNotFound”,
“operationTime” : Timestamp(1642048532, 11),
“$clusterTime” : {
“clusterTime” : Timestamp(1642048532, 11),
“signature” : {
“hash” : BinData(0,”WdMSDpXqoDKFTAGrFh0epHq2qCQ=”),
“keyId” : NumberLong(“7010334517764292616”)
}
} } :
_getErrorWithCode@src/mongo/shell/utils.js:25:13 DBCollection.prototype.findAndModify@src/mongo/shell/collection.js:725:15
DBCollection.prototype.findOneAndUpdate@src/mongo/shell/crud_api.js:900:12
@js/db_update_dups.js:1:1 2022-01-13T15:35:32.421+1100 F –
[main] failed to load: js/db_update_dups.js
2022-01-13T15:35:32.421+1100 E – [main] exiting with code -3

There is shard field in the document. Should I include that in the query? If yes,
how will be my query?