This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Path buildSubmarinePath(Size size) { | |
return Path() | |
..moveTo(size.width * 0.1950342, size.height * 7.270667) | |
..lineTo(size.width * 0.1646269, size.height * 7.270667) | |
..lineTo(size.width * 0.1646269, size.height * 7.041185) | |
..lineTo(size.width * 0.1604670, size.height * 7.041185) | |
..cubicTo( | |
size.width * 0.1576797, | |
size.height * 7.152261, | |
size.width * 0.1548923, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.dizitart</groupId> | |
<artifactId>nitrite</artifactId> | |
<version>1.0</version> | |
</dependency> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile 'org.dizitart:nitrite:1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Nitrite db = Nitrite.builder() | |
.compressed() | |
.filePath("/tmp/test.db") | |
.openOrCreate("user", "password"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create a Nitrite Collection | |
NitriteCollection collection = db.getCollection("test"); | |
// Create an Object Repository | |
ObjectRepository<Employee> repository = db.getRepository(Employee.class); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a document to populate data | |
Document doc = createDocument("firstName", "John") | |
.put("lastName", "Doe") | |
.put("birthDay", new Date()) | |
.put("data", new byte[] {1, 2, 3}) | |
.put("fruits", new ArrayList<String>() {{ add("apple"); add("orange"); add("banana"); }}) | |
.put("note", "a quick brown fox jump over the lazy dog"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// insert the document | |
collection.insert(doc); | |
// update the document | |
collection.update(eq("firstName", "John"), createDocument("lastName", "Wick")); | |
// remove the document | |
collection.remove(doc); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cursor cursor = collection.find( | |
// and clause | |
and( | |
// firstName == John | |
eq("firstName", "John"), | |
// elements of data array is less than 4 | |
elemMatch("data", lt("$", 4)), | |
// elements of fruits list has one element matching orange | |
elemMatch("fruits", regex("$", "orange")), | |
// note field contains string 'quick' using full-text index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// connect to a DataGate server localhost 9090 port | |
DataGateClient dataGateClient = new DataGateClient("http://localhost:9090") | |
.withAuth("userId", "password"); | |
DataGateSyncTemplate syncTemplate | |
= new DataGateSyncTemplate(dataGateClient, "remote-collection@userId"); | |
// create sync handle | |
SyncHandle syncHandle = Replicator.of(db) | |
.forLocal(collection) | |
// a DataGate sync template implementation | |
.withSyncTemplate(syncTemplate) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
NewerOlder