@@ -501,6 +501,18 @@ message ReserveIdsResponse {}
501
501
502
502
// A mutation to apply to an entity.
503
503
message Mutation {
504
+ // The possible ways to resolve a conflict detected in a mutation.
505
+ enum ConflictResolutionStrategy {
506
+ // Unspecified. Defaults to `SERVER_VALUE`.
507
+ STRATEGY_UNSPECIFIED = 0 ;
508
+
509
+ // The server entity is kept.
510
+ SERVER_VALUE = 1 ;
511
+
512
+ // The whole commit request fails.
513
+ FAIL = 3 ;
514
+ }
515
+
504
516
// The mutation operation.
505
517
//
506
518
// For `insert`, `update`, and `upsert`:
@@ -542,6 +554,11 @@ message Mutation {
542
554
google.protobuf.Timestamp update_time = 11 ;
543
555
}
544
556
557
+ // The strategy to use when a conflict is detected. Defaults to
558
+ // `SERVER_VALUE`.
559
+ // If this is set, then `conflict_detection_strategy` must also be set.
560
+ ConflictResolutionStrategy conflict_resolution_strategy = 10 ;
561
+
545
562
// The properties to write in this mutation.
546
563
// None of the properties in the mask may have a reserved name, except for
547
564
// `__key__`.
@@ -551,6 +568,112 @@ message Mutation {
551
568
// updated, others are left untouched.
552
569
// Properties referenced in the mask but not in the entity are deleted.
553
570
PropertyMask property_mask = 9 ;
571
+
572
+ // Optional. The transforms to perform on the entity.
573
+ //
574
+ // This field can be set only when the operation is `insert`, `update`,
575
+ // or `upsert`. If present, the transforms are be applied to the entity
576
+ // regardless of the property mask, in order, after the operation.
577
+ repeated PropertyTransform property_transforms = 12
578
+ [(google.api.field_behavior ) = OPTIONAL ];
579
+ }
580
+
581
+ // A transformation of an entity property.
582
+ message PropertyTransform {
583
+ // A value that is calculated by the server.
584
+ enum ServerValue {
585
+ // Unspecified. This value must not be used.
586
+ SERVER_VALUE_UNSPECIFIED = 0 ;
587
+
588
+ // The time at which the server processed the request, with millisecond
589
+ // precision. If used on multiple properties (same or different entities)
590
+ // in a transaction, all the properties will get the same server timestamp.
591
+ REQUEST_TIME = 1 ;
592
+ }
593
+
594
+ // Optional. The name of the property.
595
+ //
596
+ // Property paths (a list of property names separated by dots (`.`)) may be
597
+ // used to refer to properties inside entity values. For example `foo.bar`
598
+ // means the property `bar` inside the entity property `foo`.
599
+ //
600
+ // If a property name contains a dot `.` or a backlslash `\`, then that name
601
+ // must be escaped.
602
+ string property = 1 [(google.api.field_behavior ) = OPTIONAL ];
603
+
604
+ // The transformation to apply to the property.
605
+ oneof transform_type {
606
+ // Sets the property to the given server value.
607
+ ServerValue set_to_server_value = 2 ;
608
+
609
+ // Adds the given value to the property's current value.
610
+ //
611
+ // This must be an integer or a double value.
612
+ // If the property is not an integer or double, or if the property does not
613
+ // yet exist, the transformation will set the property to the given value.
614
+ // If either of the given value or the current property value are doubles,
615
+ // both values will be interpreted as doubles. Double arithmetic and
616
+ // representation of double values follows IEEE 754 semantics.
617
+ // If there is positive/negative integer overflow, the property is resolved
618
+ // to the largest magnitude positive/negative integer.
619
+ Value increment = 3 ;
620
+
621
+ // Sets the property to the maximum of its current value and the given
622
+ // value.
623
+ //
624
+ // This must be an integer or a double value.
625
+ // If the property is not an integer or double, or if the property does not
626
+ // yet exist, the transformation will set the property to the given value.
627
+ // If a maximum operation is applied where the property and the input value
628
+ // are of mixed types (that is - one is an integer and one is a double)
629
+ // the property takes on the type of the larger operand. If the operands are
630
+ // equivalent (e.g. 3 and 3.0), the property does not change.
631
+ // 0, 0.0, and -0.0 are all zero. The maximum of a zero stored value and
632
+ // zero input value is always the stored value.
633
+ // The maximum of any numeric value x and NaN is NaN.
634
+ Value maximum = 4 ;
635
+
636
+ // Sets the property to the minimum of its current value and the given
637
+ // value.
638
+ //
639
+ // This must be an integer or a double value.
640
+ // If the property is not an integer or double, or if the property does not
641
+ // yet exist, the transformation will set the property to the input value.
642
+ // If a minimum operation is applied where the property and the input value
643
+ // are of mixed types (that is - one is an integer and one is a double)
644
+ // the property takes on the type of the smaller operand. If the operands
645
+ // are equivalent (e.g. 3 and 3.0), the property does not change. 0, 0.0,
646
+ // and -0.0 are all zero. The minimum of a zero stored value and zero input
647
+ // value is always the stored value. The minimum of any numeric value x and
648
+ // NaN is NaN.
649
+ Value minimum = 5 ;
650
+
651
+ // Appends the given elements in order if they are not already present in
652
+ // the current property value.
653
+ // If the property is not an array, or if the property does not yet exist,
654
+ // it is first set to the empty array.
655
+ //
656
+ // Equivalent numbers of different types (e.g. 3L and 3.0) are
657
+ // considered equal when checking if a value is missing.
658
+ // NaN is equal to NaN, and the null value is equal to the null value.
659
+ // If the input contains multiple equivalent values, only the first will
660
+ // be considered.
661
+ //
662
+ // The corresponding transform result will be the null value.
663
+ ArrayValue append_missing_elements = 6 ;
664
+
665
+ // Removes all of the given elements from the array in the property.
666
+ // If the property is not an array, or if the property does not yet exist,
667
+ // it is set to the empty array.
668
+ //
669
+ // Equivalent numbers of different types (e.g. 3L and 3.0) are
670
+ // considered equal when deciding whether an element should be removed.
671
+ // NaN is equal to NaN, and the null value is equal to the null value.
672
+ // This will remove all equivalent values if there are duplicates.
673
+ //
674
+ // The corresponding transform result will be the null value.
675
+ ArrayValue remove_all_from_array = 7 ;
676
+ }
554
677
}
555
678
556
679
// The result of applying a mutation.
@@ -578,6 +701,11 @@ message MutationResult {
578
701
// Whether a conflict was detected for this mutation. Always false when a
579
702
// conflict detection strategy field is not set in the mutation.
580
703
bool conflict_detected = 5 ;
704
+
705
+ // The results of applying each
706
+ // [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
707
+ // order of the request.
708
+ repeated Value transform_results = 8 ;
581
709
}
582
710
583
711
// The set of arbitrarily nested property paths used to restrict an operation to
@@ -611,16 +739,13 @@ message ReadOptions {
611
739
EVENTUAL = 2 ;
612
740
}
613
741
614
- // For Cloud Datastore, if read_consistency is not specified, then lookups and
615
- // ancestor queries default to `read_consistency`=`STRONG`, global queries
616
- // default to `read_consistency`=`EVENTUAL`.
617
- //
618
- // For Cloud Firestore in Datastore mode, if read_consistency is not specified
619
- // then lookups and all queries default to `read_consistency`=`STRONG`.
742
+ // For Cloud Firestore in Datastore mode, if you don't specify
743
+ // read_consistency then all lookups and queries default to
744
+ // `read_consistency`=`STRONG`. Note that, in Cloud Datastore, global queries
745
+ // defaulted to `read_consistency`=`EVENTUAL`.
620
746
//
621
747
// Explicitly setting `read_consistency`=`EVENTUAL` will result in eventually
622
- // consistent lookups & queries in both Cloud Datastore & Cloud Firestore in
623
- // Datastore mode.
748
+ // consistent lookups and queries.
624
749
oneof consistency_type {
625
750
// The non-transactional read consistency to use.
626
751
ReadConsistency read_consistency = 1 ;
0 commit comments