How to use ampersand-collection - 10 common examples

To help you get started, we’ve selected a few ampersand-collection examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AmpersandJS / ampersand-state / test / full.js View on Github external
test('issue #82, child collections should not be cleared if they add data to themselves when instantiated', function (t) {
    var Widget = State.extend({
        props: {
            title: 'string'
        }
    });
    var Widgets = Collection.extend({
        initialize: function () {
            // some collections read from data they have immediate access to
            // like localstorage, or whatnot. This should not be wiped out
            // when instantiated by parent.
            this.add([{title: 'hi'}]);
        },
        model: Widget
    });
    var Parent = State.extend({
        collections: {
            widgets: Widgets
        }
    });
    var parent = new Parent();

    t.equal(parent.widgets.length, 1, 'should contain data added by initialize method of child collection');
github AmpersandJS / ampersand-subcollection / test / main.js View on Github external
var test = require('tape');
var mixins = require('ampersand-collection-lodash-mixin');
var Collection = require('ampersand-collection').extend(mixins);
var SubCollection = require('../ampersand-subcollection');
var Model = require('ampersand-state');
var _ = require('lodash');


// our widget model
var Widget = Model.extend({
    props: {
        id: 'number',
        name: 'string',
        awesomeness: 'number',
        sweet: 'boolean'
    }
});

// our base collection
github sinfo / eventdeck / client / js / models / company.js View on Github external
/* global app */
var AmpModel = require('ampersand-model')
var AmpCollection = require('ampersand-collection')
var options = require('../../../options')
var marked = require('../helpers/marked')
var _ = require('../helpers/underscore')

var Communication = require('./communication')
var Comment = require('./comment')
var Participation = require('./participation')

var CommunicationCollection = AmpCollection.extend({
  model: Communication
})

var CommentCollection = AmpCollection.extend({
  model: Comment
})

var ParticipationCollection = AmpCollection.extend({
  model: Participation
})

module.exports = AmpModel.extend({
  props: {
    id: ['string'],
    unread: ['boolean'],
    name: ['string'],
    description: ['string'],
    img: ['string'],
    storedImg: ['string'],
    site: ['string'],
github sinfo / eventdeck / client / js / models / speaker.js View on Github external
/* global app */
var AmpModel = require('ampersand-model')
var AmpCollection = require('ampersand-collection')
var options = require('../../../options')
var marked = require('../helpers/marked')
var _ = require('../helpers/underscore')

var Communication = require('./communication')
var Comment = require('./comment')
var Participation = require('./participation')

var CommunicationCollection = AmpCollection.extend({
  model: Communication
})

var CommentCollection = AmpCollection.extend({
  model: Comment
})

var ParticipationCollection = AmpCollection.extend({
  model: Participation
})

module.exports = AmpModel.extend({
  props: {
    id: ['string'],
    unread: ['boolean'],
    name: ['string'],
    title: ['string'],
    description: ['string'],
    information: ['string'],
    img: ['string'],
github sinfo / eventdeck / client / js / models / communication.js View on Github external
/* global app */
var AmpModel = require('ampersand-model')
var AmpCollection = require('ampersand-collection')
var timeSince = require('../helpers/timeSince')
var options = require('../../../options')
var marked = require('../helpers/marked')
var _ = require('../helpers/underscore')

var Comment = require('./comment')

var CommentCollection = AmpCollection.extend({
  model: Comment
})

module.exports = AmpModel.extend({
  props: {
    id: ['string'],
    thread: ['string'],
    event: ['string'],
    kind: ['string'],
    member: ['string'],
    text: ['string'],
    status: ['string'],
    posted: ['string'],
    updated: ['string']
  },
  collections: {
github sinfo / eventdeck / client / js / models / company.js View on Github external
/* global app */
var AmpModel = require('ampersand-model')
var AmpCollection = require('ampersand-collection')
var options = require('../../../options')
var marked = require('../helpers/marked')
var _ = require('../helpers/underscore')

var Communication = require('./communication')
var Comment = require('./comment')
var Participation = require('./participation')

var CommunicationCollection = AmpCollection.extend({
  model: Communication
})

var CommentCollection = AmpCollection.extend({
  model: Comment
})

var ParticipationCollection = AmpCollection.extend({
  model: Participation
})

module.exports = AmpModel.extend({
  props: {
    id: ['string'],
    unread: ['boolean'],
    name: ['string'],
github sinfo / eventdeck / client / js / models / speaker.js View on Github external
/* global app */
var AmpModel = require('ampersand-model')
var AmpCollection = require('ampersand-collection')
var options = require('../../../options')
var marked = require('../helpers/marked')
var _ = require('../helpers/underscore')

var Communication = require('./communication')
var Comment = require('./comment')
var Participation = require('./participation')

var CommunicationCollection = AmpCollection.extend({
  model: Communication
})

var CommentCollection = AmpCollection.extend({
  model: Comment
})

var ParticipationCollection = AmpCollection.extend({
  model: Participation
})

module.exports = AmpModel.extend({
  props: {
    id: ['string'],
    unread: ['boolean'],
    name: ['string'],
github zeropaper / visual-fiha / src / layer / threejs / state.js View on Github external
// ShapeGeometry
// SphereBufferGeometry
// SphereGeometry
// TetrahedronBufferGeometry
// TetrahedronGeometry
// TextGeometry
// TorusBufferGeometry
// TorusGeometry
// TorusKnotBufferGeometry
// TorusKnotGeometry
// TubeGeometry
// TubeBufferGeometry
// WireframeGeometry


var GeometryCollection = Collection.extend({
  mainIndex: 'name',
  // parse: collectionParse,
  // toJSON: collectionToJSON,
  // serialize: collectionToJSON,
  model: makeCollectionModel(GeometryState)
});



/***************************************\
 *                                     *
 *                                     *
 *                                     *
\***************************************/
var LightState = ThreeState.extend({
  props: {
github zeropaper / visual-fiha / src / layer / threejs / state.js View on Github external
idAttribute: 'name',
  typeAttribute: 'type',
  props: {
    type: ['string', false, null],
    name: ['string', false, null]
  },
  children: {
    color: Color
  }
});

MaterialState.types = {};



var MaterialCollection = Collection.extend({
  mainIndex: 'name',
  // parse: collectionParse,
  // toJSON: collectionToJSON,
  // serialize: collectionToJSON,
  model: makeCollectionModel(MaterialState)
});



/***************************************\
 *                                     *
 *                                     *
 *                                     *
\***************************************/

var GeometryState = ThreeState.extend({
github AmpersandJS / ampersand-collection-rest-mixin / test / main.js View on Github external
}
    };
}

var Model = AmpersandModel.extend({
    props: {
        name: 'string',
        id: 'number'
    },
    sync: function () {
        this.__syncArgs = arguments;
        return AmpersandModel.prototype.sync.apply(this, arguments);
    }
});

var Collection = AmpersandCollection.extend(RestCollectionMixins, {
    model: Model,
    sync: function () {
        this.__syncArgs = arguments;
        return RestCollectionMixins.sync.apply(this, arguments);
    }
});

test('Existence of methods', function (t) {
    t.plan(5);

    var collection = new Collection();

    t.ok(typeof collection.fetch === 'function');
    t.ok(typeof collection.create === 'function');
    t.ok(typeof collection.sync === 'function');
    t.ok(typeof collection.getOrFetch === 'function');

ampersand-collection

A way to store/manage objects or models.

MIT
Latest version published 7 years ago

Package Health Score

57 / 100
Full package analysis

Popular ampersand-collection functions