Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

Commit

Permalink
v0.3.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
jipperinbham committed Mar 21, 2017
1 parent 3577ebf commit ec95f35
Show file tree
Hide file tree
Showing 4 changed files with 152 additions and 8 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## v0.3.0 [UNRELEASED]
## v0.3.0 [2017-03-21]

### Breaking changes

Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ Native Functions

Each native function can be used as part of a `Transform` step in the pipeline.

* [goja](./adaptor/function/gojajs)
* [omit](./adaptor/function/omit)
* [otto](./adaptor/function/ottojs)
* [pick](./adaptor/function/pick)
* [pretty](./adaptor/function/pretty)
* [rename](./adaptor/function/rename)
* [skip](./adaptor/function/skip)
* [goja](./function/gojajs)
* [omit](./function/omit)
* [otto](./function/ottojs)
* [pick](./function/pick)
* [pretty](./function/pretty)
* [rename](./function/rename)
* [skip](./function/skip)

Commands
--------
Expand Down
71 changes: 71 additions & 0 deletions function/gojajs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# goja function

`goja()` creates a JavaScript VM that receives and sends data through the defined javascript function for processing. The parameter passed to the function has been converted from a go map[string]interface{} to a JS object of the following form:

```JSON
{
"ns":"message.namespace",
"ts":12345, // time represented in milliseconds since epoch
"op":"insert",
"data": {
"id": "abcdef",
"name": "hello world"
}
}
```

***NOTE*** when working with data from MongoDB, the _id field will be represented in the following fashion:

```JSON
{
"ns":"message.namespace",
"ts":12345, // time represented in milliseconds since epoch
"op":"insert",
"data": {
"_id": {
"$oid": "54a4420502a14b9641000001"
},
"name": "hello world"
}
}
```

### configuration

```javascript
goja({"filename": "/path/to/transform.js"})
```

### example

message in
```JSON
{
"_id": 0,
"name": "transporter",
"type": "function"
}
```

config
```javascript
goja({"filename":"transform.js"})
```

transform function (i.e. `transform.js`)
```javascript
function transform(doc) {
doc["data"]["name_type"] = doc["data"]["name"] + " " + doc["data"]["type"];
return doc
}
```

message out
```JSON
{
"_id": 0,
"name": "transporter",
"type": "function",
"name_type": "transporter function"
}
```
73 changes: 73 additions & 0 deletions function/ottojs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# otto function

`otto()` creates a JavaScript VM that receives and sends data through the defined javascript function for processing. The parameter passed to the function has been converted from a go map[string]interface{} to a JS object of the following form:

```JSON
{
"ns":"message.namespace",
"ts":12345, // time represented in milliseconds since epoch
"op":"insert",
"data": {
"id": "abcdef",
"name": "hello world"
}
}
```

***NOTE*** when working with data from MongoDB, the _id field will be represented in the following fashion:

```JSON
{
"ns":"message.namespace",
"ts":12345, // time represented in milliseconds since epoch
"op":"insert",
"data": {
"_id": {
"$oid": "54a4420502a14b9641000001"
},
"name": "hello world"
}
}
```

### configuration

```javascript
otto({"filename": "/path/to/transform.js"})
// transform() is also available for backwards compatibility reasons but may be removed in future versions
// transform({"filename": "/path/to/transform.js"})
```

### example

message in
```JSON
{
"_id": 0,
"name": "transporter",
"type": "function"
}
```

config
```javascript
otto({"filename":"transform.js"})
```

transform function (i.e. `transform.js`)
```javascript
module.exports=function(doc) {
doc["data"]["name_type"] = doc["data"]["name"] + " " + doc["data"]["type"];
return doc
}
```

message out
```JSON
{
"_id": 0,
"name": "transporter",
"type": "function",
"name_type": "transporter function"
}
```

0 comments on commit ec95f35

Please sign in to comment.