s3-db
s3-db copied to clipboard
.find() for the subCollection
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'
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}`;
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
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.
yes, sub collections are useful
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.
Storing related data for parent entity under that entity, IE : CompanyID => Users this way clean up and reporting is "self contained"
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?
Not yet. Should be there this week ish. Just want to be sure that I consider this feature properly. I built it without use case of my own.
On Sun, Mar 31, 2019, 3:56 PM keithburrows [email protected] wrote:
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?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/matt-filion/s3-db/issues/27#issuecomment-478393423, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUplBBk97-jOB15gif0z6NDxVypXDG1ks5vcT01gaJpZM4VhZbr .
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. https://github.com/matt-filion/s3-db/pull/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.
Any thoughts on this ^^
thats what i'd be expecting will try to test it soon
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.
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.
Bump on ^^. Want to put some effort towards this project over the weekend and be nice to have this to roll into mainline.