How to use stub.CreateTable in Hyperledger programming - go

A chaincode based on Hyperledger uses stub.PutState and stub.GetState to interact with the data base. However, if I have a struct with more than one attibutes, for example :
person {
"ID": "123",
"firstname":"joe",
"lastname":"doe",
"age":"34",
}
Then if I want to update the age, what arguments should I send to the method ?
I noticed that there is stub.CreateTable method which seems to be more convenient for my case, however, I couldn't find any document or explication about how to use this method. Would you please give me a link to the document or some brief explication please ?
Thanks.

You can not change anything on the ledger.The only way you can update the person infomation is insert a new line to cover the old.

Here is a chaincode where a table is used. You can see how to create a table, insert, delete rows :
https://github.com/hyperledger/fabric/blob/master/examples/chaincode/go/asset_management_interactive/asset_management.go#L51-L54
Hope this helps

Please look at the cases in the switch statement in the invoke method of this code. I believe the case "replaceRowTableOne": case has some insight as to what you're trying to do.
https://github.com/christo4ferris/fabric-docs/blob/master/bddtests/chaincode/go/table/table.go

Related

Using LUIS to extract an entity from a user response to a prompt for text and to store the output

I just can't find any info on this!!!
Please see the image. I want to capture the "number" from the user response as a variable (property) but can't see how to. Any ideas?!
I want to be able to do this within the composer, not with code. Surely #prebuilt number is storing the recognized entity - how do I set a variable (property) to the value of the entity? Thanks.
Here's the image of my issue
LOL - solved! The answer is to use coalesce. Keeping it here for reference for others.
Solution

Quarkus PanacheEntityBase query with IN

I have a customer entity of type PanacheEntityBase. I would like get all customers by ids
I can get it with customer.list("customerId", id) in a loop. I dont think its a good solution. I prefer using IN. Please suggest how to use IN with PanacheEntityBase
I solved the problem with customerEntity.list("customerId IN (?1)", customerIds);
Note: customersids must be a java list (Array did not work)

Discord.py: Overwrites of channel for member not working

O = discord.PermissionOverwrite()
O.manage_webhooks=True
User=get(ctx.guild.members, name="User1")
await chan.set_permissions(User, overwrite=O)
What I'm doing wrong?
I get no errors but the channels permission for the member doesn't change.
Help me please.
First, there's a built in method called get_member that I strongly suggest you use, simply using a user name is pretty easy to get messed up as someone could just change their name. But it seems your code is rather sound, so some more information (if you need to use user name) such as how you're calling this and what get exactly is would help a ton!

Odoo Warning - Missing Record Record does not exist or has been deleted . While creating new customer

Here is the screenshot of the warning which is apperaing while creating customers
I am not able to create new customers in odoo.
Initially I have done some customization in my module ...after that customization my code worked absolutely right, I have created new customers also..but after I dont know why i am not able to create new customers...
please suggest me some solution.
Thank you
I've had a similar problem related to a customized module in Odoo 10. I did some pretty thorough research and the Odoo ORM is doing some things it probably shouldn't be and that I'm not smart enough to sort out.
The sections in the Odoo 10 ORM API Documentation about creating models and fields were kind of helpful, but the documentation on the ORM is severely lacking and in some cases incorrect.
I eventually fixed it by doing the insert manually with the self.env.cr psycopg2 cursor available in the model's custom methods.
That would look something like the
from odoo import models
class your_class(models.Model):
def custom_create_method(self):
self.env.cr.execute("""
INSERT INTO customer_model_name
(name, value, other_value)
VALUES
('{}', '{}', '{}')
RETURNING id;
""")
new_id = self.env.cr.fetchone()
This has the disadvantage of introducing the possibility of an SQL injection attack into your code, so you'll need to be careful of that.
This is definitely not the ideal solution, but it does work. I believe the problem to be related to the Odoo ORM's handling of computed fields, but that is just a not-really-all-that-educated guess at what's going on.
Hope this helps.
For some reason we found a pattern where we had to comment out one of the dependancies, reinstall/update the module in question, then put it back in. In this case it was res in the custom module's __manifest__.py
i.e.:
'depends': ['base', 'res', 'sale_management', 'account', 'account_payment'],
#'depends': ['base', 'sale_management', 'account', 'account_payment'],
Becomes:
#'depends': ['base', 'res', 'sale_management', 'account', 'account_payment'],
'depends': ['base', 'sale_management', 'account', 'account_payment'],
Then install, see if the error goes away, then shut down the server and flip the comment again

Sorting a view by dropdown

Hey, i've been looking around for a ajax dropdown sorter for my Views in Drupal.
Unfortunatly, i haven't found alot of usefull information about this subject.
Can anyone tell me if theres a solution already available or can help me started on a custom module by telling me which hooks i should use?
I had a similar issue. Unfortunately I wasn't able to sort the data from the database which is by far the best way. I was however able to take the data and sort it with PHP using a preprocessor function. Depending on the name of your view, setup a function similar to the following:
function templatename_preprocess_name_of__view(&$vars)
{
//Super sweet sorting code goes here
}
The name of your view needs to follow the name of the template file that it is driven by, if there isn't on you should create one. Make sure to change dashes to underscores in your function name. Hope this is helpful. If you find a way to do it from the DB I'm all ears because that would be super awesome.

Resources