const store = Nabu
.configure({
yaml: { indent: 4 }
})
.bootstrap();import Memory from '@tashmet/memory';
import mingo from '@tashmet/mingo';
import yaml from '@tashmet/yaml';
const store = Memory
.configure({})
.use(mingo())
.use(yaml({ /* configuration options */}))
.bootstrap();const data = dedent`
title: foo
list:
- item1
- item2
`;
const pipeline: Document[] = [
{ $documents: [{ data }] },
{ $set: { data: { $yamlToObject: '$data' } } }
];
const doc = await tashmet.db('test').aggregate(pipeline).next();{ data: { title: 'foo', list: ['item1', 'item2'] } }const data = dedent`
---
title: foo
---
Content goes here
`;
const pipeline: Document[] = [
{ $documents: [{ data }] },
{
$set: {
data: {
$yamlToObject: {
data: '$data',
frontMatter: true,
contentKey: 'body'
}
}
}
}
];
const doc = await tashmet.db('test').aggregate(pipeline).next();{ data: { title: 'foo', body: 'Content goes here' } }const input = [
{ data: { foo: 'bar' } }
];
const pipeline: Document[] = [
{ $documents: input },
{ $set: { data: { $objectToYaml: '$data' } } }
];
const doc = await tashmet.db('test').aggregate(pipeline).next();