Describes live templates which are good to use in creating data classes which describes MongoDB collections.
Very specific templates, may be not useful in general, bu still goo for creating a data class to represent MongoDB collection.
Wrapped - marked as that are wrapped examples to keep proper readability of the whole table.
|
shows the final place of the cursor.
Template | Description and Enter points | Example of the result |
---|---|---|
doce |
Creates three standard annotations for MongoDB document class. |
@Document
@Canonical
@EqualsAndHashCode( excludes = [|] ) |
ciopt |
Creates an optimistic concurrency compound index annotation. |
Wrapped: the result will be in a line.
@CompoundIndex( name = 'optimistic_concurrency_idx',
def = "{ '_id': 1, 'version': 1 }" ) |
ci |
Creates a compound index annotation. Enter points:
|
Wrapped: the result will be in a line.
@CompoundIndex( name = 'index_name',
def = "{ 'first-field': 1, 'second-field': 1| }",
unique = true ) |
fnames |
Creates a nested immutable class to describe document field names. |
/**
* Contains mongo field name constants, which are publicly accessible.
*/
@Immutable
static final class FieldNames {
public static final String MIME_TYPE = 'mime-type'
public static final String ID = '_id'
public static final String VERSION = 'version'
|
} |
name |
Creates a field name variable. Creates an underlined capitalized name of the variable based on the value. Enter points:
|
public static final String FIELD_NAME = 'field-name'
| |
ids |
Creates a document id field of type String . |
/**
* Mongo generated id of the document.
*/
@Id
@Field( FieldNames.ID )
String id| |
idu |
Creates a document id field of type UUID . |
/**
* Mongo generated id of the document.
*/
@Id
@Field( FieldNames.ID )
UUID id| |
ver |
Creates a document version field declaration. |
/**
* A version field used to implement optimistic locking on entities.
*/
@Version
@Field( FieldNames.VERSION )
Long version| |
df |
Creates a general document field. Suggests a field type. Enter points:
|
/**
* Groovydoc comment.
*/
@Field( FieldNames.VALUE )
Type filedName| |
dfs |
Creates a String document field.Enter points:
|
/**
* Groovydoc comment.
*/
@Field( FieldNames.VALUE )
String fieldName| |
dfl |
Creates a long document field.Enter points:
|
/**
* Groovydoc comment.
*/
@Field( FieldNames.VALUE )
long fieldName| |
Describes the surround live templates for mongo documents. Surround live templates can be invoked by short cut Ctr+Alt+J
.
|
shows the place of the cursor.
CIS
To surround the annotation @CompoundIndex
by the annotation @CompoundIndexes
, put a cursor at the line of the former and press Ctr+Alt+J
and choose CIS
template.
Then you can use ci
live template to add another @CompoundIndex
.
Before
@CompoundIndex( name = 'index_name', def = "{ 'first-field': 1, 'second-field': 1 }", unique = true )|
After
@CompoundIndexes( [@CompoundIndex( name = 'index_name', def = "{ 'first-field': 1, 'second-field': 1 }", unique = true ),
|] )