Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.find() for the subCollection #27

Open
vanerleo opened this issue Jul 26, 2018 · 14 comments
Open

.find() for the subCollection #27

vanerleo opened this issue Jul 26, 2018 · 14 comments

Comments

@vanerleo
Copy link

calling .find() for the subcollection returns the objects of the parent collection:

const companyTable = await database.getCollection('companies');
const table = companyTable.subCollection(`${company.id}-${TABLE_NAME}`);
const documentReferences = await table.find();

documentReferences would contain the files from 'companies'

@vanerleo
Copy link
Author

the issue i think is in AWSProvider : 124

  if(fqn.name.indexOf('/')!==-1) params.Delimiter = '/';
        if(startsWith) params.Prefix = fqn.name.indexOf('/')===-1 ? startsWith : `{fqn.name.substring(fqn.name.indexOf('/')+1}/${startsWith}`;

@keithburrows
Copy link

Adding to this issue, it would be useful if subCollections were cached in some way. I am not sure of your initial thoughts behind them, but from my perspective it would be great if they could inherit as much of a collection functionality as possible

@matt-filion
Copy link
Owner

Are you both still using subCollections? I never really put a ton of effort into this as there only seemed to be a couple cases. 3.X was released just now so want to gauge if this is something i should address in the new version.

@vanerleo
Copy link
Author

yes, sub collections are useful

@matt-filion
Copy link
Owner

How do you use them? Are you iterating through a lot of records, or doing CRUD operations on an item within the collection?

I'm thinking about updating the way that find works to use the iterator pattern so you can keep going without having to use a continuation token.

@vanerleo
Copy link
Author

vanerleo commented Mar 30, 2019

Storing related data for parent entity under that entity, IE : CompanyID => Users
this way clean up and reporting is "self contained"

@keithburrows
Copy link

I am using them for monitoring a (work)flow of lambdas run (as I go tired of the dynamodb restrictions).
Each lambda run instance currently is a sub collection.
Looking at the new documentation and what you have commented, I think that subCollections do not exist in v3 at the moment?

@matt-filion
Copy link
Owner

matt-filion commented Mar 31, 2019 via email

@matt-filion
Copy link
Owner

Alright, I've got a branch for this.

https://github.com/matt-filion/s3-db/tree/3.0.3_child_collections

PR if you feel like reviewing. #38

Should work more or less the way it did before. I've removed any knowledge of delimiters and left it up to the caller to provide the prefix exactly as desired.

From the docs


subCollection(prefix): Collection

Creates a new collection where all operations will execute with the prefix in front of the id's used. So if the prefix is /users/ then when .load('1234') is called the request will result in an ID lookup for /users/1234. Similarly, all objects saved will have the prefix applied when the ID is generated by the save operation, or, when an ID is provided and it does not startWith() the configured prefix.

@matt-filion
Copy link
Owner

Any thoughts on this ^^

@vanerleo
Copy link
Author

vanerleo commented Apr 2, 2019

thats what i'd be expecting
will try to test it soon

@matt-filion
Copy link
Owner

KK. Only change i need to make is increase the version properly to 3.1.0 instead of 3.0.3 but otherwise I think it seems good to go.

@keithburrows
Copy link

Sorry, I am not going to get to this for a short while as I don't think I currently have time to upgrade to 3.n.
Thanks for all the effort though as I definitely will in the next couple of weeks.

@matt-filion
Copy link
Owner

Bump on ^^. Want to put some effort towards this project over the weekend and be nice to have this to roll into mainline.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants