admin
admin copied to clipboard
How to show entries from external DB (GRPC)
Hello! I have a small question. In my project I want to get in the admin records from an external database. I get this data from Grpc. How can I draw them in the admin panel?
r := adm.AddResource(&models.Notification{})
r.FindManyHandler = func(result interface{}, context *qor.Context) error {
getNotification := notificationGRPC.GetNotificationsReq{}
res, err := notificationAccess.Client.GetNotifications(notificationAccess.Ctx, &getNotification)
if _, ok := context.GetDB().Get("qor:getting_total_count"); ok {
*(result.(*int)) = len(res.Notifications)
return nil
}
var notificationViews = make([]models.Notification, len(res.Notifications))
for i, v := range res.Notifications {
n := models.Notification{}
n.Title = v.Title
notificationViews[i] = n
}
result = ¬ificationViews
return nil
}
type Notification struct {
Title string `json:"title"`
Text string `json:"text"`
Type string `json:"type"`
}
this comment and the nosql issue #113 might help you.
this comment and the nosql issue #113 might help you.
Thank you for help But I saw this and this doesn't help me ((
I find solution
var results = make([]*models.Notification, len(res.Notifications))
for i, v := range res.Notifications {
n := models.Notification{}
n.Title = v.Title
results[i] = &n
}
*(result.(*[]*models.Notification)) = results