mirror of
https://github.com/PretendoNetwork/wiiu-chat-secure.git
synced 2026-04-25 07:53:11 -05:00
32 lines
504 B
Go
32 lines
504 B
Go
package database
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
"go.mongodb.org/mongo-driver/mongo/options"
|
|
)
|
|
|
|
func GetUsernameFromPID(pid uint32) string {
|
|
var result bson.M
|
|
filter := bson.D{
|
|
{
|
|
Key: "pid",
|
|
Value: pid,
|
|
},
|
|
}
|
|
|
|
err := pnidCollection.FindOne(context.TODO(), filter, options.FindOne()).Decode(&result)
|
|
|
|
if err != nil {
|
|
if err == mongo.ErrNoDocuments {
|
|
return ""
|
|
}
|
|
|
|
panic(err)
|
|
}
|
|
|
|
return result["username"].(string)
|
|
}
|