question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createCollection improvements

See original GitHub issue

I think we could make a couple improvements to createCollection. For example it could be used to:

  • add custom resolvers and mutations
  • define views
  • define access restrictions

Basically, centralize everything that’s currently defined with Collection.doSomething() in one place to make the APIs cleaner. Any other ideas?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
SachaGcommented, Feb 27, 2019

Maybe something like this would work:


// client + server

export const Posts = createCollection({

  collectionName: 'Posts',

  typeName: 'Post',

  schema,
  
  checks: {
    read: {},
    create: {},
    update: {},
    delete: {},
  }

  views: {
    default: ...,
    top: ...,
    new: ...,
  }

});

// server only

import Posts from '../modules/posts/collection.js';

extendCollection(Posts, {

  resolvers: [
    ...getDefaultResolvers('Posts'),
    { 
      definition: 'randomPost: Post', 
      resolver: randomPostResolver
    }
  ],

  mutations: getDefaultMutations('Posts'),

});
0reactions
eric-burelcommented, Dec 18, 2019

Closing as this is included in 1.14 🎉

Read more comments on GitHub >

github_iconTop Results From Across the Web

CreateCollection - Amazon OpenSearch Serverless
Creates a new OpenSearch Serverless collection. For more information, see Creating and managing Amazon OpenSearch Serverless collections .
Read more >
db.createCollection() — MongoDB Manual
New collection that uses document validation. db.createCollection() is a wrapper around the database command create . The db.createCollection() ...
Read more >
CreateCollection - Fauna Documentation
The CreateCollection function is used to create a collection that groups documents. Once the collection is created, it is possible to create documents...
Read more >
create-collection — AWS CLI 2.9.5 Command Reference
create-collection ¶. Description¶. Creates a collection in an AWS Region. You can add faces to the collection using the IndexFaces operation. For example ......
Read more >
FilteredStorage::createCollection() needs to set the correct ...
After calling FilteredStorage::createCollection() a new instance of ... I don't mind small improvements that make sense even though they are ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found