(data *PartialLog)
| 368 | } |
| 369 | |
| 370 | func runOplog(data *PartialLog) error { |
| 371 | ns := strings.Split(data.Namespace, ".") |
| 372 | switch data.Operation { |
| 373 | case "i": |
| 374 | _, err := client.Database(ns[0]).Collection(ns[1]).InsertOne(context.Background(), data.Object) |
| 375 | return err |
| 376 | case "d": |
| 377 | _, err := client.Database(ns[0]).Collection(ns[1]).DeleteOne(context.Background(), data.Object) |
| 378 | return err |
| 379 | case "u": |
| 380 | _, err := client.Database(ns[0]).Collection(ns[1]).UpdateOne(context.Background(), data.Query, data.Object) |
| 381 | return err |
| 382 | case "c": |
| 383 | operation, found := ExtraCommandName(data.Object) |
| 384 | if !found { |
| 385 | return fmt.Errorf("extract command failed") |
| 386 | } |
| 387 | |
| 388 | return RunCommand(ns[0], operation, data, client) |
| 389 | default: |
| 390 | return fmt.Errorf("unknown op[%v]", data.Operation) |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | func runByte(input []byte) error { |
| 395 | data, err := ConvertEvent2Oplog(input, false) |
no test coverage detected