我在尝试根据分数和尝试对文档进行排名时遇到问题
"$rank must be specified with a top level sortBy expression with exactly one element"
Run Code Online (Sandbox Code Playgroud)
查询是:
$resultListing = UserScore::raw(function ($collection){
return $collection->aggregate([
['$setWindowFields' => [
'sortBy' => [ 'score'=>-1, 'attempts'=>1],
'output' => [ 'scoreRank' => ['$rank'=>(object) [] ] ],
]]
]);
});
Run Code Online (Sandbox Code Playgroud)
给出的语法是:
{
$setWindowFields: {
partitionBy: <expression>,
sortBy: {
<sort field 1>: <sort order>,
<sort field 2>: <sort order>,
...,
<sort field n>: <sort order>
},
Run Code Online (Sandbox Code Playgroud)
是否可以根据多个字段对文档进行排名?
I have the master database with login table and corresponding database settings for each user. On login I should dynamically change the db settings fetching from the table. I can change the db connection but this is not persisting.
Config::set("database.connections.mysql", [
'driver' => 'mysql',
"host" => $usr_host,
"database" => $usr_database,
"username" => $usr_username,
"password" => $usr_password,
...
]);
Run Code Online (Sandbox Code Playgroud)
edit: New database is created for each user when he/she registers with the app and thus i dont have the database connection …
laravel ×2
mysql ×2
database ×1
laravel-8 ×1
mongodb ×1
multi-tenant ×1
php ×1
phpmyadmin ×1
ranking ×1