feathersjs - Custom create method in service - feathersjs

I need some help. I need to insert other objects when I call e.g. a item service create method. But I don't know how to achieve this in the service class of the item model.
I got a database table where I need to store an Id of another table entry, but first I need to insert this entry.
And I want to this this with one call.
Thanks!

Ok, it's simple. Use the feathers CLI to generate a custom service.

Related

Backendless + Zapier. Create record with foreign relationship

I'm new to the world of Low Code app development, and so far I'm pulling my hair out.
I'm using a third party web app to submit JSON formatted data to Zapier via webhook, and then submit that to Backendless with codeless API that creates a record. I'm running into two issues that I can't figure out how to solve.
Backendless record creation with foreign key relationship. I'm creating a record in Table A, but that needs to have a relationship to Table B. I have it set up as such in Backendless, but in Zapier I don't see an option to populate the table_b_id in the Table A record I'm creating. What am I missing here?
After creating the Table A record, I want to create multiple records in Table C that are children of the Table A record. How on earth do I do this? With Python + SQL, I could do it in 2 minutes, but for the life of me I can't figure out how to do it the LowCode way using either Zapier or Backendless.
Any help would be appreciated! I'm totally stumped.
Backendless actions for Zapier let you save/update/delete an object in a single table. These are distinct API operations. Creating a relationship is a separate API call that doesn't have a corresponding action in Zapier's Backendless integration. However, you can create a relation between the object you're saving and a related "parent" (or "child") table using an API event handler in business logic. It can be done with Java, JS or Codeless. The event handler you'd be creating is afterSave.
You can save multiple objects with a single call using Codeless. The simplest way to do this by using the Bulk Create block: https://prnt.sc/x6cwp4. The objects connector should be a list of objects to save in the table.

Saving data to Order custom fields with API in Infusionsoft

I've added a couple of custom fields to the Order in the Infusionsoft and now I'm trying to save data into those fields with API. I thought I could use Update method of data service like this:
apiProxy.Update(InfusionsoftHelper._InfusionsoftApiKey, "Order", orderId, obj);
Unfortunately it does know Order table. I can't find an appropriate table name in their documentation.
Has anyone done something similar? Thanks in advance!
The "Order" table is called "Job" in the API.

NSIndexPath save to another entity

I am almost done researching for my application. The last thing that I need to be able to learn how to do is the following situation: Let's say I have created a UItableview drilldown app, but once the user gets to the end of that drill down (their choices on a specific dog product for instance are now very specific), they can save that information. What I want my app to do here is, at the end of the drilldown, save their entire nsindexpath as another entity so that I can send this information later up to my MySQL database. My question is, how could I re-save an nsstring from an nsindexpath in another entity?
Start writing code instead of researching your entire app's architecture before you start it. You really only will learn from actually programming.
Use Core Data
Use tableView:didSelectRowAtIndexPath: to obtain the selected tableview cell's indexPath and store the indexPath or the data as needed.
I agree with runmads suggestions. CoreData will probably make your life easier in the long run. To answer your question though:
Don't save the table view's NSIndexPath. The selection index path is a view related property (in MVC terms). Your users choice belongs to the model domain. It's bad practice to mix the two and if you later insert new choices in one of your tables, your stored index paths will become invalid.
Instead create something like a UserChoice object or a dictionary or an array which you can pass down your tableview controllers as the user drills down. When the user selects a cell, add the primary key of the associated data object to your array. At the end, store the primary keys you've collected along the way into your database.

Linq-to-SQL - how to make a data entity that is not attached to the database

Let's say I have a database that stores Fruit and FruitBaskets, and it's already populated with plenty of each. In my code I'm using Linq-to-Sql so that I can treat the rows of the database as instances of the OO classes Fruit and FruitBasket. Let's say that I want to create a temporary FruitBasket in code, process with it, but I do not want the FruitBasket to be persisted to the database. How do I achieve this using Linq-to-Sql?
The default I've found in Linq-to-Sql is that if I create a new, empty FruitBasket and add a Fruit to it that I had retrieved from the database, then the new FruitBasket will be automatically inserted to the data base upon my call to dataContext.SubmitChanges() (whether or not I have called insertUponSubmit()). Usually this is the right thing , but sometimes I want to be able to create a new FruitBasket without having it automatically inserted into the DB. Ideas? Best practices?
If you set DataContext.ObjectTrackingEnabled = false; then it shout prevent this. You need to make sure you set it before querying the data context.

SQL - adding fields to query to sorty by

I'm working with a third party software package that is on it's own database. We are using it for the user management back bone on our application. We have an API to retrieve data and access info.
Due to the nature of information changing daily, we can only use the user_id as a pseudo FK in our application, not storing info like their username or name. The user information can change (like person name...don't ask).
What I need to do is sort and filter (paging results) one of my queries by the person's name, not the user_id we have. I'm able to get an array of the user info before hand. Would my best bet be creating a temporary table that adds an additional field, and then sorts by that?
Using MySQL for the database.
You could adapt the stored procedure on this page here to suit your needs the stored procedure is a multi purpose one and is very dynamic, but you could alter it to suit your needs for filtering the person table.
http://weblogs.asp.net/pwilson/archive/2003/10/10/31456.aspx
You could combine the data into an array of objects, then sort the array.
Yes, but you should consider specifically where you will make the temporary table. If you do it in your web application then your web server is stuck allocating memory for your entire table, which may be horrible for performance. On the other hand, it may be easier to just load all your objects and sort them as suggested by eschneider.
If you have the user_id as a parameter, you can create a user defined function which retrieves the username for you within the stored procedure.
Database is on different servers. For all purposes, we access it via an API and the data is then turned into an array.
For now, I've implemented the solution using LINQ to filter and out the array of objects.
Thanks for the tips and helping me go in the right direction.