Added a feature for managing mongoDB document versioning.
The default key is "schema_version"
If the version is not specified, t is automatically set to 1
Usage
use MongoDB\Laravel\Eloquent\HasDocumentVersion;
use MongoDB\Laravel\Eloquent\Model as Eloquent;
/** @property int $schema_version */
class SchemaVersionned extends Eloquent
{
use HasSchemaVersion;
public const int SCHEMA_VERSION = 1;
protected $connection = 'mongodb';
protected $collection = 'documentVersion';
protected static $unguarded = true;
}
For overwrite version key:
/** @property int $__v */
class DocumentVersion extends Eloquent
{
use HasSchemaVersion;
protected $connection = 'mongodb';
protected $collection = 'documentVersion';
protected static $unguarded = true;
public static function getSchemaVersionKey(): string
{
return '__v';
}
}
For update document version:
/** @property int $schema_version */
class DocumentVersion extends Eloquent
{
use HasSchemaVersion;
public const int SCHEMA_VERSION = 2;
protected $connection = 'mongodb';
protected $collection = 'documentVersion';
protected static $unguarded = true;
}
Added a feature for managing mongoDB document versioning. The default key is "schema_version" If the version is not specified, t is automatically set to 1
Usage
For overwrite version key:
For update document version: