Skip to content

Instantly share code, notes, and snippets.

Tom Boutell boutell

Block or report user

Report or block boutell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View apostrophe-caches-index.js
self.getCollection = function(callback) {
return self.apos.db.collection('aposCache', function(err, collection) {
if (err) {
return callback(err);
}
self.cacheCollection = collection;
return async.series({
keyIndex: function(callback) {
return self.cacheCollection.ensureIndex({ key: 1, cache: 1 }, { unique: true }, callback);
},
View elasticsearch.json
{
"body": [
{
"_index": "testaposdocsdefault",
"_type": "aposDoc",
"_id": "cjnyogcfp0001n3uktsbndy6m"
},
{
"type": "apostrophe-global",
"typeESExact": "apostrophe-global",
View ApostropheStringField-sample-2.js
import ApostropheFieldMixin from '../mixins/ApostropheFieldMixin.js';
export default {
mixins: [ ApostropheFieldMixin ],
name: 'ApostropheStringField',
methods: {
validate(value) {
if (this.field.required) {
if (!value.length) {
return 'required';
View ApostropheFieldMixin-sample-1.js
module.exports = {
props: {
value: Object,
field: Object,
context: Object
},
data() {
return {
next: (this.value.data !== undefined) ? this.value.data : (this.field.def || ''),
error: false
View ApostrophePiecesInsertModal-sample-1.vue
<template>
<ApostropheModal @close="$emit('close')">
<template slot="header">
<p>New {{ options.label }}</p>
</template>
<template slot="body">
<ApostropheSchemaEditor :fields="options.schema" v-model="pieceInfo" />
</template>
<template slot="footer">
<slot name="footer">
View ApostropheStringField-sample-1.vue
<template>
<ApostropheFieldset :field="field" :error="error">
<template slot="body">
<input v-model="next" />
</template>
</ApostropheFieldset>
</template>
View ApostropheFieldset-sample-1.vue
<template>
<fieldset :class="cssClass">
<label class="apos-field-label">{{ field.label }}</label>
<div v-if="field.help" class="apos-field-help">{{ field.help }}</div>
<slot name="body"></slot>
</fieldset>
</template>
View ApostropheSchemaEditor-sample-1.vue
<template>
<div class="apos-schema">
<component
v-for="field in fields"
:is="options.components.fields[field.type]"
v-model="fieldState[field.name]"
:field="field"
:context="next.data"
/>
</div>
@boutell
boutell / gist:db0ca16e4b6de7a592cb79a4ed4a700c
Created Aug 17, 2018
mongodb query for first array element being "null" does not obey the usual "undefined properties match null" rule
View gist:db0ca16e4b6de7a592cb79a4ed4a700c
// This will find "bar" and "woo". But it does not find "foo".
(function() {
db.dropDatabase();
db.docs.insert([{
title: 'foo',
ids: []
}, {
title: 'bar'
}, {
@boutell
boutell / gist:8ea95b723b253cc697607a1cc51dd5fb
Created Mar 22, 2018
Apostrophe CMS addColumns example
View gist:8ea95b723b253cc697607a1cc51dd5fb
[
{
name: 'title',
label: 'Title'
},
{
name: 'updatedAt',
label: 'Last Updated',
partial: function(value) {
if (!value) {
You can’t perform that action at this time.