Meteor.js collection & user permission structure - javascript

We are starting development of a meteor app that allows users to create a profile, submit a set of search criteria and receive products (held in the app's db) curated by an administrator. I am wondering what the most elegant way of setting up the collections for this would be.
So far, our thinking is to:
Automatically generate user id's (accounts-ui package) and roles (alanning:meteor-roles package) as soon as the search process is
started
Add all user information, including the user id and role generated in step 1, to a "clients" collection
Add all search criteria selected by the user, as well as the user-id, to a separate "searches" collection.
Use search criteria to filter objects in a "products" collection, and deliver results to an admin who then manually curates from
filtered results.
Given the information I've provided, does this sound like the most elegant structure?

Related

Not able to add relational data to a collection type from post request in strapi v4

So I can add the relational data from the admin panel in strapi, so in this case there is a collection type called reviews and it has many to one relationship with another collection type called products
In postman when I add a review I’m not able to add relation to it. Currently I’m adding the relation via id as that is the standard.
I was able to do in this in v3, but in strapi v4 for some reason the relation is not getting added.
I had the same problem and solved it by going to "Settings" > "Users permissions plugins" > "Roles" > "Public" (or "Authenticated", depending on if you want only logged-in users to access it) > "Products" and click "find" and "findOne" and save it.
If "find" and "findOne" in a collection aren't enabled for "Public" or "Authenticated" users, then Strapi won't bother finding the id in the collection that the relation is referring to because you haven't allowed those users to access that data.

Get all subscription groups and product ids from itunes connect

I want to get all subscription groups (with product ids) in itunes connect from my backend side. I am looking at the documentation but I can not find any endpoint for that.
I mean, something similar to google which you can specify the packageName and it returns all product ids:
https://developers.google.com/android-publisher/api-ref/inappproducts/get
this.androidpublisher.inappproducts.list({
auth: this.authClient,
packageName: packageName
},
Does Apple provide an endpoint for this?
This can only be done from within your app with an SKProductsRequest. The products could be different based on the user's country (availability, pricing, etc.).
It may be easier to just store a hardcoded mapping of your product IDs -> data on your server.

Firebase >> User Favorites List

I need a little assistance with my app. I'm not asking for a handout, just some guidance as to where to begin. The basic idea is for logged in users to be able to favorite videos, and to have them persist when logged in.
My app uses the YouTube API (Playlist Items) to display videos from my public playlists within my app. I'm using firebase auth to register and login users, but I have yet to implement the RTD. This is where I need some assistance in structuring my data & organizing my app.
I don't want favorite lists created for every user by default, nor do I want to store false values and have to loop through them. I'd only like to set a favorites list if the user requests to do so, and the values are true. I'm open to suggestions regarding structuring my data, but I was thinking something simple like this:
"favorites": {
"John Doe": {
"video1ID": true,
"video2ID": true,
}
}
Videos are contained within cards using a .each function from within the API response. Included in these cards are "favorite" toggle switches that I'd like a user to be able to toggle and add a favorite video to their list.
YouTube provides Video ID's from within their JSON response. I was thinking that assigning a boolean to that video ID would get the job done, but I have no idea where to begin.
Something like:
function writeFavoritesList (name, videoID, toggleValue) {
firebase.database().ref('favorites/' + userId).set({
name: displayName,
videoID: videoID,
toggleValue: true
});
}
I'm very much a newb to anything outside of WordPress, so I hope I'm on the right track. Any help appreciated. Thanks! :)
Looks great. If this were another database, you could consider storing the video IDs in an array, but this being the firebase RealTime Database, you're much better off with objects, which you've already got.
You could modify your structure slightly to take advantage of RTDs push() key generation if you ever intend on sorting your favourite videos. To do so, instead of making the key the videoID and the value the boolean status, you could generate a key using firebase's push() key generation and make the value the videoID. "The unique key generated by push() are ordered by the current time, so the resulting list of items will be chronologically sorted. The keys are also designed to be unguessable (they contain 72 random bits of entropy)."
"favorites": {
"uid1": {
"uniqueKey1": videoID1,
"uniqueKey2": videoID2,
}
}
To generate a push() key, use: const key = firebase.database().ref().push().key.
More info: https://firebase.google.com/docs/reference/js/firebase.database.Reference#push
Saw your Guru post. I think the best way for you to learn is to delve deep into the documentation and figure this out for yourself. If you're truly committed to learning this stuff you'd be doing yourself a disservice to have someone else write the code for you.
I'd start with the GCP(Google Cloud Platform) cloud firestore docs and read through the Concepts section in its entirety:
https://cloud.google.com/firestore/docs/concepts
The firebase site mirrors parts of the GCP documenation, but also covers client implementations:
https://firebase.google.com/docs/firestore/
To get the most out of these docs use the nav sidebar on the left to drill down into all the various Cloud Firestore topics. They go into how to structure your database and provide sample code for you to analyse and play with.
You'll see the terms Documents and Collections thrown around a lot. A Document is somewhat equivalent to a JSON Object. A Collection is a list of documents; similar to an array of JSON objects. But here's where things get interesting; Documents can reference Collections (aka Subcollections):
So I would structure your database as follows:
Create a Users collection
Whenever a new user signs into your app, create a user document and add it to the Users collection.
The first time a user selects a favorite video create a Favorites collection and add it to the user document; then add favorite documents to the Favorites collection for this user
There is a Javascript/Web client (you've seem to already have it loaded from what I've seen in the repo link you provided on Guru). Here's the reference documentation for it:
https://firebase.google.com/docs/reference/js/firebase.firestore
The classes, methods and properties defined in those reference docs are what you'll be calling from within your jquery code blocks.
Good luck and stick with it.

how to write meteor migration script to insert one collection data to another collection?

i need to insert one collection data to another collection. how can i write migration script for this purpose. card payments and corporate customer payment are two collections.
corporate customer payment collection has below attributes customerID,outsTanding,date,amount,headOfficeId,insertDate
cards payment collection has below attributes
customerID,amount,card,packageId,cardId,classType,expireDate,headOfficeId,insertDate
i'm inserting cards payment collection following datas to corporate customer payment collection.
CustomerID -> card.customerID
outsTanding -> card.cartId
date -> card.insertDate
amount -> card.amount
headOfficeId ->card.headOfficeId
so how can i apply this change for old datas. how need i write meteor migration for up and down functions.
anyone who had this issue assist me.
thanks

Rally App SDK 2.0: Filtering a store of Users by UserPermissions

I am attempting to build a store that consists of only Users that are not disabled and have editor permissions on the selected Project. However, UserPermissions is an array of UserPermission objects, which makes such a filter rather complex. It seems that a UserPermission can be of the WorkspacePermission or the ProjectPermission type. So, it looks like I would first have to check the type of the UserPermission, and then check whether the _refObjectName contains the name of the selected Project and "Editor," OR, alternatively, delve deeper into the ProjectPermission itself and check the Project's name and the Role for "Editor" separately. I have attempted to use the filterBy function, passing in a function that takes a record and an id, but I am unable to hit the breakpoint I set inside that function, so I have no idea whether it is working. The results displayed in a combobox certainly do not seem to match what I am querying for. Any suggestions?
Edit1: I have tried modifying the query to scope to the particular project name, but I receive this error: "Could not parse: Attribute \"Project\" on type ProjectPermission is not allowed in query expressions." Is there any way to get around this?
Here is the modified query, excluding the actual project name:
https://rally1.rallydev.com/slm/webservice/x/ProjectPermission.js?pagesize=1&fetch=true&includeSchema=true&includeMeta=true&query=%28%28Role%20=%20Editor%29%20AND%20%28Project.Name%20%3D%20%22{PROJECT NAME HERE}%22%29%29
Edit2: Just thought someone might want to know. I received this error when trying to add another parameter to the query to filter by a User's DisplayName.
"Could not parse: UserPermission does not support complex queries yet. You can only query by Role OR by User, not both."
Edit3: I am having additional trouble with a call to get all the Project Permissions for a User based on their DisplayName. The query, as far as I'm concerned, is formatted as it should be. However, only results for some users are returned, and I have no idea why other users aren't included. I have even tried modifying it to query on FirstName, and the permissions for the user are not included in the result set.
https://rally1.rallydev.com/slm/webservice/x/ProjectPermission.js?pagesize=200&fetch=true&includeSchema=true&includeMeta=true&query=%28User.DisplayName%20%3D%20%22{INSERT NAME HERE}%22%29
You can query the Permissions endpoint to make sure that the that permission is for an Editor you can see the json for that request by following this link.
To get the list of Users that are active you query them with disabled = false like this.
Once you have Permission data in memory you can filter out the users do not that have Edit permissions and match them with the list of active users.

Categories

Resources