Code examples

Additional information: Section under development

This part of our website is still under development and major parts of its content are not published yet.

Follow us on social media to get notified when new content is released.

The Basics

Install dependecies

Add mishmash io to your project:

// C# examples coming soon
// Java examples coming soon
$ npm install mishmash-io
// PHP example coming soon
$ pip install mishmash-io-client
# Ruby examples coming soon

Connect

Import and instantiate:

// C# examples coming soon
// Java examples coming soon
const Mishmash = require('mishmash-io')
mishmash = new Mishmash()
// PHP example coming soon
from Mishmash import Mishmash
mishmash = Mishmash()
# Ruby examples coming soon

You are now connected and mishmash will ‘hold’ all your data as if it was in the local memory of your app.

Additional information: Note

There is no API or framework beyond the simple use of ‘local’ to your app ‘mishmash’ variables.

Store Data

To store data, just assign values, arrays and objects to the properties of a mishmash variable:

// C# examples coming soon
// Java examples coming soon
mishmash.myObjects[] = {
"a": 42,
"b": "a lazy dog",
"c": [obj1, obj2]
}
// PHP example coming soon
mishmash.myObjects = {
"a": 42,
"b": "a lazy dog",
"c": [obj1, obj2]
}
# Ruby examples coming soon

That’s it - your data is stored and available for later use under mishmash.myObjects.

Additional information: Note

As a database, mishmash io has no schema. It just uses whatever ‘schema’ you create by the way you organize and store your data.

Access Data

To pull data into your app, just loop over a mishmash variable:

// C# examples coming soon
// Java examples coming soon
for (o in mishmash.myObjects) {
if (o.a === 42) {
// do something
}
}
// PHP example coming soon
for o in mishmash.myObjects:
if o.a == 42:
# do something
# Ruby examples coming soon

The body of the for loop will now operate on your app server with data arriving from the mishmash io cluster. However, remember that this will only run at the speed of your app server and network.

Additional information: Tip

To make your code run faster than that, see the advanced examples below.

Advanced

Building ‘mishmashes’

When building ‘mishmashes’ - those portions of the data that your code needs to work on - you don’t have to strictly follow the hierarchy of properties, members and indexes that you created when you stored the data.

To simplify your work, you can grab the data items at any level:

// C# examples coming soon
// Java examples coming soon
mishmash_b = mishmash.b
mishmash_dogs = mishmash['a lazy dog']
// PHP example coming soon
mishmash_b = mishmash.b
mishmash_dogs = mishmash['a lazy dog']
# Ruby examples coming soon

And you can build mishmashes by putting together or slicing apart completely unrelated branches of your data:

// C# examples coming soon
// Java examples coming soon
cake = mishmash('chocolate',
'bananas')
coffee = mishmash.coffees.black
// PHP example coming soon
cake = mishmash('chocolate',
'bananas')
coffee = mishmash.coffees.black
# Ruby examples coming soon

Additional information: Note

There’s much more that you can do to build mishmashes - scroll down to find out more.

‘Query’ with code

To achieve super-fast execution of complex logic, don’t pull data into the app - instead, push your code into the mishmash io cluster:

// C# examples coming soon
// Java examples coming soon
mishmash.myObjects(
function(input) {
for (o in input) {
if (o.a === 42) {
// do something complex
}
}
}
)
// PHP example coming soon
def function(input):
for o in input:
if o.a == 42:
# do something complex
mishmash.myObjects(function)
# Ruby examples coming soon

The supplied function will now be automatically optimized and ‘executed’ in parallel across all cluster nodes that contain portions of myObjects and any other input.

Additional information: Note

The code is transformed into a ‘parallel’ equivalent by combining syntax analysis and knowledge of input data.

Advanced Algorithms

Learn mishmash io through examples.

We developed a little app that analyzes football data to automatically find interesting statistics about the next match.

The details on how we did it are a great place to get started with mishmash io.

Additional information: This section is being updated

We’re currently working on adding more examples.

Follow us on Social Media where we will also publish material on topics like algorithms, Machine Learning, AI and more.